Skip to content

fix(trello): use OAuth Authorization header for attachment downloads#950

Merged
zbigniewsobiecki merged 1 commit intodevfrom
fix/trello-attachment-oauth-header
Mar 18, 2026
Merged

fix(trello): use OAuth Authorization header for attachment downloads#950
zbigniewsobiecki merged 1 commit intodevfrom
fix/trello-attachment-oauth-header

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

  • Root cause: trelloClient.downloadAttachment() was appending key and token as query parameters to the URL. Trello's attachment download endpoint (/1/cards/{id}/attachments/{id}/download/{filename}) does not accept query-param auth — it requires an Authorization: OAuth request header, causing 401s and null returns silently.
  • Fix: Switch to downloadMedia(url, { Authorization: \OAuth oauth_consumer_key="...", oauth_token="..."` })— the same header-auth pattern the JIRA client already uses with Basic auth. TheauthHeadersparameter ofdownloadMedia()` already existed for exactly this purpose.
  • Tests: Rewrote all four downloadAttachment unit tests to assert header-based auth (no query params on the URL, correct Authorization header value). Test assertions use toEqual for clean object comparison, no type casts.

Closes the image download null warnings first observed in run 6a3d92d5.

Test plan

  • npx vitest run tests/unit/trello/client.test.ts — 53 tests pass
  • npm test — 5963 tests pass, no regressions
  • npx tsc --noEmit — no type errors

🤖 Generated with Claude Code

Trello's attachment download endpoint (/1/cards/{id}/attachments/{id}/download/...)
requires an Authorization: OAuth header and does NOT accept key/token query-param
auth, causing all attachment downloads to return 401 and downloadAttachment() to
return null (root cause of the image-download null warnings seen in run 6a3d92d5).

Switch from appending key/token as query params to passing an OAuth header via the
existing authHeaders parameter of downloadMedia() — the same pattern already used
by the JIRA client with Basic auth. Update all four downloadAttachment unit tests to
assert header-based auth and use realistic Trello attachment URLs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit ef6f01d into dev Mar 18, 2026
8 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the fix/trello-attachment-oauth-header branch March 18, 2026 20:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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