test(node): Assert absence of PII attributes in OpenAI integration tests - #24031
itz-puneet wants to merge 3 commits into
Conversation
The OpenAI integration tests assert which attributes are present when `sendDefaultPii` is disabled, but never assert that the PII-gated attributes are absent. A regression which leaked prompt or response content onto spans would therefore pass the existing suite. Adds an explicit check over every span in the envelope, for both `instrument.mjs` (recording disabled) scenarios, covering the four content-bearing attributes which the paired `instrument-with-pii.mjs` tests assert are present: - `gen_ai.input_messages` - `gen_ai.system_instructions` - `gen_ai.response.text` - `gen_ai.embeddings.input` Iterating the whole envelope rather than the individually inspected spans also catches content leaking onto spans the tests do not assert against directly. The same gap exists in the anthropic, langchain and google-genai suites; happy to follow up in a separate PR. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change is a targeted, consistent test hardening that directly addresses the documented gap without introducing behavioral or structural risk.
Pull request overview
Strengthens the OpenAI Node integration test suite to prevent regressions where PII-bearing GenAI content attributes are accidentally attached to spans while sendDefaultPii is disabled, aligning coverage with the concerns raised in #19801.
Changes:
- Adds explicit assertions that content-bearing GenAI attributes are absent when
sendDefaultPiiis disabled. - Applies the absence checks across all spans in the captured envelope for both chat and embeddings scenarios to catch leaks on uninspected spans.
File summaries
| File | Description |
|---|---|
| dev-packages/node-integration-tests/suites/tracing/openai/test.ts | Adds envelope-wide assertions ensuring PII-gated GenAI attributes are undefined when sendDefaultPii is disabled (chat + embeddings). |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
1 similar comment
|
Oh, wait a second, I think this might be outdated, since we removed that field in v11. |
…i in OpenAI assertions sendDefaultPii was removed in v11 in favour of dataCollection. The disabled scenarios now opt out via dataCollection.genAI, so the comment describing the absence assertions is updated to match.
|
Thanks for catching that, @isaacs — you're right that The assertions themselves still apply though. On I've pushed a987ded, which updates the code comment to reference |
The OpenAI integration tests assert which attributes are present when GenAI recording is disabled, but never assert that the gated attributes are absent. As #19801 notes, a regression that leaked prompt or response content onto spans would pass the existing suite.
#19801 was filed against
sendDefaultPii, which was removed in v11. The gap still exists under its replacement: the disabled scenarios now opt out withdataCollection: { genAI: { inputs: false, outputs: false } }, whichresolveAIRecordingOptionsturns intorecordInputs/recordOutputs. Since v11 defaults to collecting GenAI inputs and outputs, the explicit opt-out is the path that most needs a guard.This adds an explicit absence check to both
instrument.mjs(recording disabled) scenarios — chat and embeddings — covering the four content-bearing attributes that the pairedinstrument-with-pii.mjstests assert are present:gen_ai.input.messages(gated byinputs)gen_ai.system_instructions(gated byinputs)gen_ai.embeddings.input(gated byinputs)gen_ai.response.text(gated byoutputs)The check iterates every span in the envelope rather than only the spans asserted individually above, so content leaking onto an uninspected span is also caught.
for (const span of container.items)already appears 4 times in this file, so the shape matches the surrounding style.Scope
Only the
openaisuite here, to keep the diff reviewable. The same gap exists inanthropic,langchainandgoogle-genai— happy to follow up in a separate PR if you'd like the same treatment there.I did not use the
flare-redactapproach suggested in the issue comments, sinceAGENTS.mdsays not to add dependencies unless explicitly asked. These assertions use vitest built-ins only.Testing note
I was unable to run
yarn install,yarn lint,yarn testoryarn formatlocally — my environment enforces an npm registry publish-date cutoff that blocks resolving this repo's dependency tree. The change is additive test assertions with no production code touched, and I verified the constants used are still imported by this file ondevelop, but CI is the first real execution of these assertions. Please flag anything it turns up and I'll fix promptly.Closes #19801