Skip to content

fix(watchsync): keep the MDBList API key out of error text - #1351

Merged
Quick104 merged 7 commits into
mainfrom
fix/watchsync-mdblist-key-redaction
Sep 24, 2026
Merged

Quick104 merged 7 commits into
mainfrom
fix/watchsync-mdblist-key-redaction

Conversation

@Quick104

@Quick104 Quick104 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A (same bug class as #692, which covers the separate internal/mdblist discovery client)
Validation tasks: none
Stack: builds on #1350; merge that first.

The MDBList watch-sync provider sends the user's API key as a query parameter. Go transport errors wrap *url.Error, whose message includes the full request URL, key included. Those errors reach the connection's last_error and the sync run error that the web settings page shows, and they reach logs. internal/logredact redacts by attribute name, so it doesn't catch a key inside error text.

Approach

  • The keyed URL is built in one place, inside the single-request helper, and never leaves it.
  • Transport and request-build errors go through logredact.SanitizeURLError, which drops the query string and keeps the cause chain. errors.Is still matches context.Canceled and context.DeadlineExceeded, and errors.As still finds net.Error timeouts.
  • If the key still appears in the error text, it is masked. One such case is a redirect with an unparseable Location header, which Go quotes verbatim. The masked error keeps the original as its cause for errors.Is and errors.As, so classification still works.
  • Error-body excerpts mask the key in raw and query-escaped form. A key fragment left at the 4 KB truncation point is also dropped.

internal/mdblist (#692) is not touched here.

Validation

  • A sentinel key is checked against every error in the chain across six request types and five failure sources: a failing transport, a closed server, a malformed base URL, a redirect loop, and an unparseable redirect. The 429-then-transport-error path, cancellation, timeout classification, and body masking are also covered.
  • With the redaction disabled, the new tests fail.
  • go test -race ./internal/watchsync/... passes. make lint-changed reports 0 issues.

Risks

None identified. Error messages keep method and path; only the query string is dropped.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code subagents
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated; the maintainer set scope and product decisions. Human review of the diff is pending.
  • Adversarial review: An independent Claude Opus 5.5 subagent reviewed P1–P4 read-only, including every MDBList request path, the error chain, %v formatting, and error-body excerpts, for remaining key leaks and for lost errors.Is/errors.As behavior. No findings for this PR.

🤖 Generated with Claude Code

Quick104 and others added 2 commits September 24, 2026 00:42
Trakt and Simkl answered every non-2xx the same way, so a 429 never
became a RateLimitedError and the sync service never deferred the
account. Both providers now map 429 (and Simkl's documented
rate_limit/RATE_LIMIT bodies) to RateLimitedError with the provider's
Retry-After, retry short waits in place, and pace authenticated writes
to one per second per access token as the providers document.

Retry-After parsing and the per-credential write limiter move into
internal/watchsync so MDBList, Trakt and Simkl share them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The MDBList watch-sync provider puts the API key in the request query
string. Transport errors wrap *url.Error, whose message includes that
URL, and those errors reach the connection's last_error, sync run
errors shown in the web UI, and logs. Build the keyed URL only inside
the single request helper, sanitize transport and request-build errors
with logredact.SanitizeURLError, and mask the key (raw or escaped) in
error-body excerpts. Cancellation and timeout classification is kept.

Same bug class as #692, which covers the separate internal/mdblist
discovery client.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104 Quick104 mentioned this pull request Sep 24, 2026
1 of 2 tasks
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: d86b7da9-46ad-447e-a908-71972233d42e

📥 Commits

Reviewing files that changed from the base of the PR and between cc4102f and 4a32d98.

📒 Files selected for processing (10)
  • internal/apiv2/request_lifecycle.go
  • internal/apiv2/request_lifecycle_test.go
  • internal/watchsync/providers/mdblist/provider.go
  • internal/watchsync/providers/mdblist/provider_test.go
  • internal/watchsync/providers/simkl/provider.go
  • internal/watchsync/providers/simkl/ratelimit_test.go
  • internal/watchsync/providers/trakt/provider.go
  • internal/watchsync/providers/trakt/ratelimit_test.go
  • internal/watchsync/ratelimit.go
  • internal/watchsync/ratelimit_test.go
 _____________________________
< I wish to make a complaint. >
 -----------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps greptile-apps 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.

Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T02:40:27.046167Z 4a32d98 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Quick104 and others added 2 commits September 24, 2026 01:18
A provider 429 during a watch-provider call, such as Trakt's slow_down
answer to a device-code poll, now reaches clients as a rate-limited
problem carrying the provider's wait instead of an internal error.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e86836bb2

ℹ️ 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".

Quick104 and others added 3 commits September 24, 2026 02:10
A local limiter refuses at once when the next slot lies past the
context deadline. That was an ordinary error, so watched exports that
were never sent were marked failed. The refusal is now a
RateLimitedError, which leaves the work pending for a later run; a
cancelled context still returns its own error. MDBList's limiter gets
the same treatment.

Starting Trakt device authorization now reports a 429 as a rate limit
with the provider's Retry-After, like polling and token refresh.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
When a transport error quoted the keyed URL in its own message, the
masking fallback replaced it with a plain error, so errors.Is and
errors.As no longer matched cancellations, deadlines, or net.Error
timeouts. The masked error now answers Is and As from the original,
without an Unwrap that would expose its message.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Base automatically changed from fix/watchsync-provider-rate-limits to main September 24, 2026 12:55
@Quick104
Quick104 merged commit 1b82554 into main Sep 24, 2026
10 of 17 checks passed
@Quick104
Quick104 deleted the fix/watchsync-mdblist-key-redaction branch September 24, 2026 12:56
rangoDJ added a commit to rangoDJ/silo-server that referenced this pull request Sep 27, 2026
main fixed the watchsync MDBList provider's key leak independently
(Silo-Server#1351: logredact.SanitizeURLError plus a masked, non-unwrapping error),
so its provider.go and provider_test.go are kept whole and this branch's
provider changes are dropped. jellycompat/handlers_items_test.go keeps
main's rewrite.

internal/mdblist/discovery.go still returned request and transport errors
unredacted on main. Rework this branch's fix there to the provider's
shape: logredact.SanitizeURLError, then mask any remaining raw or
query-escaped key in a redactedError that has no Unwrap. errors.Unwrap can
no longer reach the unmasked cause, while Is/As keep sentinel matching and
net.Error timeout classification at any depth.

The tests now walk the whole unwrap chain (messages and url.Error.URL),
never print the key on failure, and cover timeout classification.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

1 participant