Skip to content

Fix IAST JDBC instrumentation when getMetadata throws non-SQLException#11420

Open
smola wants to merge 1 commit into
masterfrom
smola/gentle-parsedbinfo
Open

Fix IAST JDBC instrumentation when getMetadata throws non-SQLException#11420
smola wants to merge 1 commit into
masterfrom
smola/gentle-parsedbinfo

Conversation

@smola
Copy link
Copy Markdown
Member

@smola smola commented May 19, 2026

What Does This Do

  • Make JDBCDecorator handle non-SQLException exception from connection.getMetadata(), and handle it like any other exception.

Motivation

  • We see this method throwing internal exceptions in IAST (seen via telemetry, no app impact), because the connection pool implementation intentionally throws errors that do not extend from SQLException.

Additional Notes

  • Database monitoring was not affected, as it had an outer catch for Throwable.
  • For IAST, there was no impact to application behavior (there's a catch-all for exceptions in IAST), but this inhibited IAST sinks for beforePrepare.

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@smola smola added type: bug Bug report and fix inst: jdbc JDBC instrumentation comp: database Database Monitoring labels May 19, 2026
@datadog-datadog-prod-us1
Copy link
Copy Markdown
Contributor

datadog-datadog-prod-us1 Bot commented May 19, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 7 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-java | Ubuntu_20_amd64.SI94: [test-app-java-alpine]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). AssertionError: _container_tags_validator failed to validate trace_id: 44736803481784963 in tests/auto_inject/utils.py:21

DataDog/apm-reliability/dd-trace-java | Ubuntu_20_amd64.SI94: [test-app-java-container]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). AssertionError: _container_tags_validator failed to validate trace_id: 92340049443385284 in tests/auto_inject/utils.py:79 while running test_origin_detection.

DataDog/apm-reliability/dd-trace-java | Ubuntu_23_10_arm64.SI94: [test-app-java-alpine]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). AssertionError: _container_tags_validator failed to validate trace_id: 30713731604332072 in tests/auto_inject/utils.py at line 79.

View all 7 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6a51445 | Docs | Datadog PR Page | Give us feedback!

@smola smola added comp: asm iast Application Security Management (IAST) and removed comp: database Database Monitoring labels May 20, 2026
@smola smola changed the title fix(jdbc): catch any throwable when getting JDBC getMetadata Fix IAST JDBC instrumentation when getMetadata throws non-SQLException May 20, 2026
@smola smola added the tag: ai generated Largely based on code generated by an AI or LLM label May 20, 2026
@smola smola force-pushed the smola/gentle-parsedbinfo branch from 362658e to 6a51445 Compare May 20, 2026 08:10
@smola smola marked this pull request as ready for review May 20, 2026 08:11
@smola smola requested review from a team as code owners May 20, 2026 08:11
@smola smola requested review from daniel-romano-DD, jandro996 and jordan-wong and removed request for a team May 20, 2026 08:11
Copy link
Copy Markdown
Member

@jandro996 jandro996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for catch this :)

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a51445772

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
}

void 'metadata runtime exception does not report unexpected exception on connection method'() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move the new JDBC coverage to JUnit 5

The repository guidance in /workspace/dd-trace-java/AGENTS.md says test changes must use JUnit 5 and explicitly says not to write new Groovy/Spock tests, migrating existing Groovy tests instead. This adds a new Spock feature method in IastJDBCTest.groovy, so the change violates the local test-framework rule even though it covers the intended scenario; please add this coverage in JUnit 5 rather than extending the Groovy spec.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not migrating a full test class in the same PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: asm iast Application Security Management (IAST) inst: jdbc JDBC instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants