← Back to Pull requests

sdk/resource: trim an OTEL_RESOURCE_ATTRIBUTES value that fails to decode #9442

Open
unknown opened this pull request with 208 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 06, 2026 00:12 UTC
Author

OTEL_RESOURCE_ATTRIBUTES="key= %invalid " sets key to " %invalid ", though doc.go:22 says values are trimmed. constructOTResources trims before it decodes, but when url.PathUnescape fails it falls back to the raw v (sdk/resource/env.go:85). #2963 added that fallback so a bad value is never empty, and it took field[1], which the old code had trimmed. TestInvalidPercentDecoding has no spaces in its input.

The fix trims v once, before the decode, so the fallback still keeps the text and only drops the whitespace. Values that decode come out as before. No issue is open for this one.

Before, with the new test and no fix:

$ cd sdk/resource && go test -count=1 -run TestInvalidPercentDecoding .   # base 4aafbd546
--- FAIL: TestInvalidPercentDecodingTrimsValue (0.00s)
        	            	actual  : ... Key:"key", Value:attribute.Value{vtype:4, numeric:0x0, stringly:" %invalid ", ...
FAIL	go.opentelemetry.io/otel/sdk/resource	0.006s

After:

$ cd sdk/resource && go test -count=1 -race ./... && go vet ./...   # go1.27.1
ok  	go.opentelemetry.io/otel/sdk/resource	1.151s
$ golangci-lint run --config ../../.golangci.yml ./...   # 2.15.0, the internal/tools pin
0 issues.
$ make precommit && git status --short   # rc=0, tree clean
# not run: the integration and compatibility workflows

The spec says to discard the whole variable on a decode error (resource/sdk.md). I left the #2963 retain-and-report behaviour alone, since dropping it changes what Detect returns and TestInvalidPercentDecoding pins that. @MrAlias, you co-authored #2963: is the trim enough here, with spec discard as its own change if you want it?

Diff: 208 lines (+156 / -52) across 2 files Reviewer: dashpole Review duration: 1350m
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.36) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 208 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
42%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.320
Real PR Conversation Timeline
1 comments
"Review active on #9442"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 43.0% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.4% (MEDIUM) · Higher = larger blast radius
36.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 43.0% · Lower = rushed or shallow review
43.0%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 20.8% · Safe to merge
20.8%