Skip to content

fix(trace): redact endpoint config errors - #91

Open
XnLemon wants to merge 1 commit into
mainfrom
codex/phase2-redaction-boundary-sweep
Open

fix(trace): redact endpoint config errors#91
XnLemon wants to merge 1 commit into
mainfrom
codex/phase2-redaction-boundary-sweep

Conversation

@XnLemon

@XnLemon XnLemon commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Objective

Close a Phase2 trace configuration redaction gap by ensuring invalid telemetry endpoint errors do not expose credentials or API keys from endpoint URLs.

Changes

  • Redacted trace endpoint URL values in parseEndpointURL and the outer HTTP trace initialization error context.
  • Added URL userinfo redaction that handles both scheme and no-scheme endpoint inputs.
  • Wrapped parse errors with sanitized Error() text while preserving Unwrap() for programmatic error inspection.
  • Added regression coverage for missing-host and invalid-escape endpoint failures containing userinfo passwords and API keys.

Validation

  • go test ./telemetry/trace
  • go vet ./telemetry/trace
  • git diff --check
  • open-code-review subagent review loop: 0 High / 0 Medium / 0 Low

Known Risks / Limitations

  • User-facing trace config errors intentionally redact endpoint credentials; exact raw endpoint failures remain available only through controlled internal error unwrapping.

Follow-up

  • Continue Phase2 closure on the next independently reviewable governance/security gap.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

English

  • Overview: Redacts credentials, API keys, and userinfo from trace endpoint configuration errors, including endpoints with or without schemes. Wrapped parse errors retain Unwrap() behavior, while HTTP trace initialization errors no longer expose raw endpoint values.
  • Compatibility and risks: No exported API changes. Error-message contents will change, which may affect consumers matching exact text; underlying error classification and unwrapping remain available. Redaction logic should be monitored for unusual endpoint formats.
  • Validation: Run trace package tests, go vet, whitespace checks, and confirm regression coverage for missing-host and invalid-escape URLs containing passwords or API keys.
中文

中文

  • 变更概述: 对 trace endpoint 配置错误中的凭据、API key 和 userinfo 进行脱敏,支持带 scheme 和不带 scheme 的 endpoint。包装后的解析错误仍保留 Unwrap() 行为,HTTP trace 初始化错误也不会再暴露原始 endpoint。
  • 兼容性与风险: 未修改导出 API。错误消息内容会变化,可能影响依赖精确文本匹配的调用方;底层错误分类和解包能力保持不变。需要关注特殊 endpoint 格式下的脱敏完整性。
  • 建议验证: 运行 trace 包测试、go vet 和空白检查,并确认回归测试覆盖包含密码或 API key 的缺少 host 及非法转义 URL。

Walkthrough

Trace endpoint parsing and HTTP exporter initialization now redact sensitive URL values in configuration errors. Tests cover invalid endpoints containing credentials and API keys while preserving parse-failure context.

Changes

Trace endpoint redaction

Layer / File(s) Summary
Redacted endpoint error flow
telemetry/trace/trace.go
Endpoint parsing and HTTP exporter initialization sanitize URL values, while a custom error preserves the underlying parse error for unwrapping.
Sensitive endpoint regression coverage
telemetry/trace/trace_test.go
Invalid endpoint variants verify that credentials and API keys are absent while parse context remains present.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: redacting endpoint config errors in trace handling.
Description check ✅ Passed The description matches the changeset and validation details, covering redaction, wrapping, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/phase2-redaction-boundary-sweep

Comment @coderabbitai help to get the list of available commands.

@XnLemon
XnLemon force-pushed the codex/phase2-usage-record-redaction branch from 9c6837b to 782305b Compare July 11, 2026 13:38
@XnLemon
XnLemon force-pushed the codex/phase2-redaction-boundary-sweep branch from 12886ba to 960c075 Compare July 11, 2026 13:38
@XnLemon
XnLemon changed the base branch from codex/phase2-usage-record-redaction to main July 13, 2026 02:23
@XnLemon
XnLemon force-pushed the codex/phase2-redaction-boundary-sweep branch from 960c075 to 4cc0a1a Compare July 13, 2026 02:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
telemetry/trace/trace_test.go (1)

162-193: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test the preserved error-chain contract.

The %zz cases verify sanitized text only. Also assert errors.As(err, &urlErr) reaches the underlying *url.Error; otherwise a future removal of Unwrap() breaks callers without failing this regression test.

中文

测试保留的错误链契约。

%zz 用例目前只验证了脱敏后的错误文本。还应断言 errors.As(err, &urlErr) 能获取底层 *url.Error;否则未来移除 Unwrap() 会破坏调用方,但该回归测试不会失败。

As per path instructions, prioritize “error semantics” and cover “regression scenarios.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@telemetry/trace/trace_test.go` around lines 162 - 193, Extend
TestStartHTTP_InvalidEndpointURLRedactsSensitiveConfig to verify the preserved
error chain for the invalid endpoint cases: declare a *url.Error target and
assert errors.As(err, &urlErr) succeeds, especially for the %zz inputs, while
retaining the existing redaction and endpoint-context checks.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@telemetry/trace/trace_test.go`:
- Around line 162-193: Extend
TestStartHTTP_InvalidEndpointURLRedactsSensitiveConfig to verify the preserved
error chain for the invalid endpoint cases: declare a *url.Error target and
assert errors.As(err, &urlErr) succeeds, especially for the %zz inputs, while
retaining the existing redaction and endpoint-context checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 50cd32fc-15e8-46ad-a3d8-86f7920429fd

📥 Commits

Reviewing files that changed from the base of the PR and between 361e2a4 and 4cc0a1a.

📒 Files selected for processing (2)
  • telemetry/trace/trace.go
  • telemetry/trace/trace_test.go

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants