question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

improperly quoted identifiers in sql queries

See original GitHub issue

Current Behavior:

Across multiple tables, i’m seeing these errors in the log:

19:31:33.885 WARN [Persist] Insert of object "alpine.model.EventServiceLog@66cf1966" using statement "INSERT INTO "EVENTSERVICELOG" ("COMPLETED","STARTED","SUBSCRIBERCLASS") VALUES (?,?,?)" failed : ERROR: column ""ID"" does not exist
  Hint: Perhaps you meant to reference the column "EVENTSERVICELOG.ID".
  Position: 101
19:31:33.885 WARN [Persist] Insert of object "alpine.model.EventServiceLog@169aa3e1" using statement "INSERT INTO "EVENTSERVICELOG" ("COMPLETED","STARTED","SUBSCRIBERCLASS") VALUES (?,?,?)" failed : ERROR: column ""ID"" does not exist
  Hint: Perhaps you meant to reference the column "EVENTSERVICELOG.ID".                  
  Position: 101
19:31:33.887 DEBUG [DefaultObjectGenerator] Creating config property: scanner / vulndb.api.oauth1.consumerKey
19:31:33.891 DEBUG [DefaultObjectGenerator] Creating config property: scanner / vulndb.api.oath1.consumerSecret
19:31:33.892 WARN [General] ExecutionContext closed with active transaction, so rolling back the active transaction
19:31:33.895 DEBUG [DefaultObjectGenerator] Creating config property: artifact / cyclonedx.enabled
19:31:33.899 WARN [General] ExecutionContext closed with active transaction, so rolling back the active transaction
19:31:33.901 ERROR [LoggableUncaughtExceptionHandler] An unknown error occurred in an asynchronous event or notification thread
javax.jdo.JDODataStoreException: Insert of object "alpine.model.EventServiceLog@66cf1966" using statement "INSERT INTO "EVENTSERVICELOG" ("COMPLETED","STARTED","SUBSCRIBERCLASS") VALUES (?,?,?)" failed : ERROR: column ""ID"" does not exist
  Hint: Perhaps you meant to reference the column "EVENTSERVICELOG.ID".
  Position: 101
        at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:542)
        at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:720)
        at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:740)
        at alpine.persistence.AlpineQueryManager.createEventServiceLog(AlpineQueryManager.java:916)
        at alpine.event.framework.BaseEventService.lambda$publish$0(BaseEventService.java:97)  
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.postgresql.util.PSQLException: ERROR: column ""ID"" does not exist
  Hint: Perhaps you meant to reference the column "EVENTSERVICELOG.ID".
  Position: 101
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2674)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2364)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:354)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:484)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:404)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:162)
        at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:130)
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
        at org.datanucleus.store.rdbms.ParamLoggingPreparedStatement.executeUpdate(ParamLoggingPreparedStatement.java:393)
        at org.datanucleus.store.rdbms.SQLController.executeStatementUpdate(SQLController.java:435)
        at org.datanucleus.store.rdbms.request.InsertRequest.execute(InsertRequest.java:485)   
        at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObjectInTable(RDBMSPersistenceHandler.java:162)
        at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObject(RDBMSPersistenceHandler.java:138)
        at org.datanucleus.state.StateManagerImpl.internalMakePersistent(StateManagerImpl.java:4569)
        at org.datanucleus.state.StateManagerImpl.makePersistent(StateManagerImpl.java:4546)
        at org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextImpl.java:2026)
        at org.datanucleus.ExecutionContextImpl.persistObjectWork(ExecutionContextImpl.java:1869)
        at org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java:1724)
        at org.datanucleus.ExecutionContextThreadedImpl.persistObject(ExecutionContextThreadedImpl.java:219)
        at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:715)
        ... 6 common frames omitted


9:34:41.526 WARN [Persist] Insert of object "org.dependencytrack.model.DependencyMetrics@e1dd838" using statement "INSERT INTO "DEPENDENCYMETRICS" ("COMPONENT_ID","CRITICAL","FINDINGS_AUDITED","FINDINGS_TOTAL","FINDINGS_UNAUDITED","FIRST_OCCURRENCE","HIGH","RISKSCORE","LAST_OCCURRENCE","LOW","MEDIUM","POLICYVIOLATIONS_AUDITED","POLICYVIOLATIONS_FAIL","POLICYVIOLATIONS_INFO","POLICYVIOLATIONS_LICENSE_AUDITED","POLICYVIOLATIONS_LICENSE_TOTAL","POLICYVIOLATIONS_LICENSE_UNAUDITED","POLICYVIOLATIONS_OPERATIONAL_AUDITED","POLICYVIOLATIONS_OPERATIONAL_TOTAL","POLICYVIOLATIONS_OPERATIONAL_UNAUDITED","POLICYVIOLATIONS_SECURITY_AUDITED","POLICYVIOLATIONS_SECURITY_TOTAL","POLICYVIOLATIONS_SECURITY_UNAUDITED","POLICYVIOLATIONS_TOTAL","POLICYVIOLATIONS_UNAUDITED","POLICYVIOLATIONS_WARN","PROJECT_ID","SUPPRESSED","UNASSIGNED_SEVERITY","VULNERABILITIES") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" failed : ERROR: column ""ID"" does not exist
  Hint: Perhaps you meant to reference the column "DEPENDENCYMETRICS.ID".
  Position: 868
19:34:41.528 WARN [Retrieve] Fetch of object "org.dependencytrack.model.Project@2e0bc292" using statement "SELECT "A0"."ACTIVE","A0"."AUTHOR","A0"."CLASSIFIER","A0"."CPE","A0"."DESCRIPTION","A0"."DIRECT_DEPENDENCIES","A0"."GROUP","A0"."LAST_BOM_IMPORTED","A0"."LAST_BOM_IMPORTED_FORMAT","A0"."LAST_RISKSCORE","A0"."NAME","A0"."PUBLISHER","A0"."PURL","A0"."SWIDTAGID","A0"."UUID","A0"."VERSION" FROM "PROJECT" "A0" WHERE "A0"."ID" = ?" failed : ERROR: current transaction is aborted, commands ignored until end of transaction block
19:34:41.528 WARN [Persistence] Exception thrown by StateManager.isLoaded for field=20 of StateManager[pc=org.dependencytrack.model.Project@2e0bc292, lifecycle=P_NONTRANS] : ERROR: column ""ID"" does not exist
  Hint: Perhaps you meant to reference the column "DEPENDENCYMETRICS.ID".
  Position: 868
19:34:41.531 WARN [Persistence] Exception thrown by StateManager.isLoaded for field=20 of StateManager[pc=org.dependencytrack.model.Project@2e0bc292, lifecycle=P_CLEAN] : ERROR: column ""ID"" does not exist
  Hint: Perhaps you meant to reference the column "DEPENDENCYMETRICS.ID".
  Position: 868
19:34:41.531 WARN [General] ExecutionContext closed with active transaction, so rolling back the active transaction
19:34:41.561 ERROR [MetricsUpdateTask] An unknown error occurred while updating metrics
javax.jdo.JDODataStoreException: Iteration request failed : SELECT 'org.dependencytrack.model.ProjectProperty' AS "DN_TYPE","A0"."DESCRIPTION","A0"."GROUPNAME" AS "NUCORDER0","A0"."ID","A0"."PROPERTYNAME" AS "NUCORDER1","A0"."PROPERTYTYPE","A0"."PROPERTYVALUE" FROM "PROJECT_PROPERTY" "A0" WHERE "A0"."PROJECT_ID" = ? ORDER BY "NUCORDER0","NUCORDER1"
	at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:542)
	at org.datanucleus.api.jdo.JDOAdapter.getApiExceptionForNucleusException(JDOAdapter.java:543)
	at org.datanucleus.state.StateManagerImpl.isLoaded(StateManagerImpl.java:4128)
	at org.dependencytrack.model.Project.dnGetuuid(Project.java)
	at org.dependencytrack.model.Project.getUuid(Project.java:349)
	at org.dependencytrack.tasks.MetricsUpdateTask.updatePortfolioMetrics(MetricsUpdateTask.java:107)
	at org.dependencytrack.tasks.MetricsUpdateTask.inform(MetricsUpdateTask.java:66)
	at alpine.event.framework.BaseEventService.lambda$publish$0(BaseEventService.java:99)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2674)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2364)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:354)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:484)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:404)
	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:162)
	at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)
	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
	at org.datanucleus.store.rdbms.ParamLoggingPreparedStatement.executeQuery(ParamLoggingPreparedStatement.java:375)
	at org.datanucleus.store.rdbms.SQLController.executeStatementQuery(SQLController.java:553)
	at org.datanucleus.store.rdbms.scostore.FKListStore.listIterator(FKListStore.java:1138)
	at org.datanucleus.store.rdbms.scostore.AbstractListStore.listIterator(AbstractListStore.java:92)
	at org.datanucleus.store.rdbms.scostore.AbstractListStore.iterator(AbstractListStore.java:82)
	at org.datanucleus.store.types.wrappers.backed.List.loadFromStore(List.java:267)
	at org.datanucleus.store.types.wrappers.backed.List.initialise(List.java:216)
	at org.datanucleus.store.types.TypeManagerImpl.createSCOInstance(TypeManagerImpl.java:471)
	at org.datanucleus.store.rdbms.mapping.java.AbstractContainerMapping.replaceFieldWithWrapper(AbstractContainerMapping.java:442)
	at org.datanucleus.store.rdbms.mapping.java.AbstractContainerMapping.postFetch(AbstractContainerMapping.java:459)
	at org.datanucleus.store.rdbms.request.FetchRequest.execute(FetchRequest.java:502)
	at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.fetchObject(RDBMSPersistenceHandler.java:316)
	at org.datanucleus.state.StateManagerImpl.loadFieldsFromDatastore(StateManagerImpl.java:1542)
	at org.datanucleus.state.StateManagerImpl.loadUnloadedFieldsInFetchPlan(StateManagerImpl.java:3897)
	at org.datanucleus.state.StateManagerImpl.isLoaded(StateManagerImpl.java:4112)
	... 8 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: column ""ID"" does not exist
  Hint: Perhaps you meant to reference the column "DEPENDENCYMETRICS.ID".
  Position: 868

Steps to Reproduce:

Build latest master branch.

Expected Behavior:

No errors

Environment:

  • Dependency-Track Version: master branch
  • Distribution: Docker
  • BOM Format & Version: n/a
  • Database Server: PostgreSQL 14.0
  • Browser: N/A

Additional Details:

Looks like the SQL generation is quoting identifiers wrong for postgresql. It would be easier if the tables were created in a case-insensitive name manner

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ruckccommented, Dec 15, 2021

That snapshot version works.

0reactions
github-actions[bot]commented, Jan 15, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quoted identifiers should not be used - SonarSource Rules
PL/SQL static code analysis ... SQL statements should not join too many tables ... Quoted identifiers can contain any character, which can be...
Read more >
SET QUOTED_IDENTIFIER (Transact-SQL) - Microsoft Learn
When SET QUOTED_IDENTIFIER is ON (default), identifiers can be delimited by double quotation marks (" "), and literals must be delimited by ...
Read more >
Common SQL syntax errors and how to resolve them
In this article, we are going to describe some of the most common SQL syntax errors, and explains how you can resolve these...
Read more >
INSERT failed because the following SET options have ...
QUOTED_IDENTIFIER is a "sticky" option so the setting in effect when the procedure was created is used at runtime.
Read more >
Improper SET Option Errors | Dan Guzman's Blog
The implication is one needs to explicitly add a SET QUOTED_IDENTIFIER ON statement to T-SQL scripts executed by SQL Server Agent T-SQL job ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found