libertymutual / ssh-key-enforcer-stash

Layers additional controls over Bitbucket's SSH key features that enforce the stronger controls required in an enterprise environment.
Apache License 2.0
6 stars 7 forks source link

SQL Exception Error occurring during the SshKeyCreatedEvent #25

Closed jdesulme closed 7 years ago

jdesulme commented 7 years ago

The following error is being thrown in Stash 3.11.3

2017-03-22 10:30:39,948 ERROR [AtlassianEvent::thread-12] RandomUser @EWV8VAx630x33149209x1 10.X.X.X,X.X.X.X, "POST /rest/keys/1.0/projects/XXXXXX/repos/vision-process/ssh HTTP/1.1" c.a.s.i.e.AsyncBatchingInvokersTransformer There was an exception thrown trying to dispatch event 'com.atlassian.stash.ssh.SshKeyCreatedEvent[source=com.atlassian.stash.internal.key.ssh.DefaultSshKeyService$9@31f06eeb]' for the invoker 'SingleParameterMethodListenerInvoker{method=public void com.lmig.forge.stash.ssh.events.GeneralEventListener.mylistener(com.atlassian.stash.event.StashEvent), listener=com.lmig.forge.stash.ssh.events.GeneralEventListener@5f4fc609}'.
java.lang.RuntimeException: There was a SQL exception thrown by the Active Objects library:
Database:
    - name:PostgreSQL
    - version:9.4.7
    - minor version:4
    - major version:9
Driver:
    - name:PostgreSQL Native Driver
    - version:PostgreSQL 9.4 JDBC4.1 (build 1201)
org.postgresql.util.PSQLException: ERROR: value too long for type character varying(767)
    at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54) ~[atlassian-event-2.3.5.jar:na]
    at com.atlassian.stash.internal.event.AsyncBatchingInvokersTransformer$AsyncInvokerBatch.invoke(AsyncBatchingInvokersTransformer.java:100) ~[stash-platform-3.11.3.jar:na]
    at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1$1.run(AsynchronousAbleEventDispatcher.java:48) [atlassian-event-2.3.5.jar:na]
    at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:38) [sal-core-2.13.4.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
    ... 1 frame trimmed
Caused by: com.atlassian.activeobjects.internal.ActiveObjectsSqlException: There was a SQL exception thrown by the Active Objects library:
Database:
    - name:PostgreSQL
    - version:9.4.7
    - minor version:4
    - major version:9
Driver:
    - name:PostgreSQL Native Driver
    - version:PostgreSQL 9.4 JDBC4.1 (build 1201)
org.postgresql.util.PSQLException: ERROR: value too long for type character varying(767)
    at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.create(EntityManagedActiveObjects.java:113) ~[na:na]
    at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects.create(TenantAwareActiveObjects.java:299) ~[na:na]
    at com.lmig.forge.stash.ssh.ao.EnterpriseKeyRepositoryImpl.saveExternallyGeneratedKeyDetails(EnterpriseKeyRepositoryImpl.java:69) ~[na:na]
    at com.lmig.forge.stash.ssh.keys.EnterpriseSshKeyServiceImpl.isKeyValidForUser(EnterpriseSshKeyServiceImpl.java:73) ~[na:na]
    at com.lmig.forge.stash.ssh.keys.EnterpriseSshKeyServiceImpl.removeKeyIfNotLegal(EnterpriseSshKeyServiceImpl.java:82) ~[na:na]
    at com.lmig.forge.stash.ssh.events.GeneralEventListener.mylistener(GeneralEventListener.java:53) ~[na:na]
    at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36) ~[atlassian-event-2.3.5.jar:na]
    ... 6 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(767)
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2270) ~[postgresql-9.4-1201-jdbc41.jar:9.4]
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1998) ~[postgresql-9.4-1201-jdbc41.jar:9.4]
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255) ~[postgresql-9.4-1201-jdbc41.jar:9.4]
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:570) ~[postgresql-9.4-1201-jdbc41.jar:9.4]
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:420) ~[postgresql-9.4-1201-jdbc41.jar:9.4]
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:366) ~[postgresql-9.4-1201-jdbc41.jar:9.4]
    at com.jolbox.bonecp.PreparedStatementHandle.executeUpdate(PreparedStatementHandle.java:203) ~[bonecp-0.7.1.RELEASE.jar:0.7.1.RELEASE]
    at net.java.ao.db.PostgreSQLDatabaseProvider.executeInsertReturningKey(PostgreSQLDatabaseProvider.java:356) ~[na:na]
    at net.java.ao.DatabaseProvider.insertReturningKey(DatabaseProvider.java:1970) ~[na:na]
    at net.java.ao.db.PostgreSQLDatabaseProvider.insertReturningKey(PostgreSQLDatabaseProvider.java:313) ~[na:na]
    at net.java.ao.EntityManager.create(EntityManager.java:398) ~[na:na]
    at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.create(EntityManagedActiveObjects.java:109) ~[na:na]
    ... 12 common frames omitted
eddiewebb commented 7 years ago

Oh that's a good one, ill have to make sure AO supports clobs in Postgres.

eddiewebb commented 7 years ago

Digging in with Jean, only a single user sees this error, and they keys they need are being created, unable to replicate. Leaving open, but not a widespread issue.

eddiewebb commented 7 years ago

This bug affects Stash version only. The appropriate ActiveObjects annotation to support postgres was introduced as part of the Bitbucket refactoring, https://github.com/Libertymutual/ssh-key-enforcer-stash/commit/6694fec78555c4f822c09c48416db6be819b1077#diff-9ef1fa3682b21340a295d9f2c1161e4b

https://developer.atlassian.com/docs/atlassian-platform-common-components/active-objects/ao-0-18-x-upgrade-guide#AO0.18.xUpgradeGuide-Added@StringLength

I am closing again as Won't Fix since Stash is deprecated by Vendor, but will accept a PR if anyone needs the Stash version to work on postgres.