Reproduce runaway User-Agent accumulation under context reuse (regression test)#5809
Draft
renaudhartert-db wants to merge 5 commits into
Draft
Reproduce runaway User-Agent accumulation under context reuse (regression test)#5809renaudhartert-db wants to merge 5 commits into
renaudhartert-db wants to merge 5 commits into
Conversation
Integration tests emit a User-Agent that repeats "sdk/sdkv2 resource/<name>" many times, tripping context-integrity checks. addContext only branches the context and passes it down, so it cannot duplicate dimensions on its own; a long User-Agent arriving here means a caller upstream re-applies the wrap to an already-enriched context. Log a stack trace the first few times the incoming User-Agent already exceeds 256 bytes to identify that caller. Co-authored-by: Isaac
Contributor
|
Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes. |
…T MERGE) The CI -json reporter drops passing-test output, so a log-only tripwire is invisible unless the test fails. Trigger precisely (a healthy context has exactly one "sdk/sdkv2"; >=2 means addContext ran on an already-enriched context) and return a diag error so the offending test fails and the runner echoes the captured stack. Co-authored-by: Isaac
Replaces the diagnostic tripwire with a regression test. addContext appends "sdk/sdkv2 resource/<name>" to the context user-agent via useragent.InContext (append, no dedup). With a fresh per-RPC context (normal Terraform flow) exactly one pair is added; when a caller reuses the enriched context across operations, the pairs accumulate linearly, producing the multi-kilobyte header seen on the heatseeker probe's gcpWorkspaceBrowserLogin requests. The test asserts both: the fresh path stays at 1, and 50 reused-context operations yield 50 repeats. Co-authored-by: Isaac
…T MERGE) The full integration suite emits User-Agents that repeat sdk/sdkv2 resource/<name> hundreds of times. addContext only branches the context, so a fresh wrap should never see an incoming context already carrying resource/ dimensions. Log a stack trace the first 40 times it does, to identify the caller threading an enriched context back into the wrap. Co-authored-by: Isaac
…MERGE) Log lines are dropped by the -json reporter and the long UA never appears in client TF_LOG, so the only reliable surface is a failing test. Fail the op and embed runtime.Stack the first 6 times a wrap sees an incoming context already carrying a resource/ dimension (the onset of accumulation), pinpointing the caller that threads an enriched context back into the wrap. Co-authored-by: Isaac
Contributor
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Adds a regression test (
common.TestUserAgentAccumulatesWhenContextReused) that reproduces the extremely longUser-Agentheaders reported from the integration-test probe (tf-integration-tests/... sdk/sdkv2 resource/directoryrepeated hundreds of times, which trip context-integrity checks and fire false Sev0s).Root cause:
addContext(common/context.go) appendssdk/sdkv2andresource/<name>to the context's user-agent data viauseragent.InContext, which appends without deduplication. The normal Terraform flow hands each CRUD a fresh per-RPC context, so exactly one pair is added (bounded). When a caller reuses the enriched context across operations — a long-lived process threading one context — the pairs accumulate linearly into a multi-kilobyte header. The runaway surfaces on the GCP account->workspace token-exchange request (gcpWorkspaceBrowserLogin,auth/google-credentials), which inherits the resource operation's context.The test asserts both halves: a fresh context per operation stays at one pair; 50 reused-context operations yield 50 repeats (matching the observed shape). It passes today (documents the accumulation) and will keep the header bounded once the SDK adds dedup at the builder (databricks/databricks-sdk-go#1718).
Tests
make test(the new unit test) run locallydocs/folderinternal/acceptanceNEXT_CHANGELOG.mdfile