Skip to content

fix(webapp): org avatars blocked by img-src CSP and avatar overflow on failed load - #4600

Open
kathiekiwi wants to merge 7 commits into
mainfrom
fix/org-avatar-csp-overflow
Open

fix(webapp): org avatars blocked by img-src CSP and avatar overflow on failed load#4600
kathiekiwi wants to merge 7 commits into
mainfrom
fix/org-avatar-csp-overflow

Conversation

@kathiekiwi

@kathiekiwi kathiekiwi commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

What & why

Org avatars disappeared from the sidebar, replaced by alt text spilling across it. Two bugs stacked: the document img-src CSP pins the Google favicon endpoint org avatars are stored as, but Google 302-redirects it to tN.gstatic.com and CSP re-checks the redirect target, so the avatar is refused. Changelog images served from trigger.dev in the agent chat were also missing from the allowlist. And Avatar.tsx had no clipping and no error fallback, so a refused image degraded into overflowing alt text.

What's inside

CSP allowlistapp/utils/cspImageOrigins.ts: the base sources gain the four gstatic shards t0t3.gstatic.com, path-pinned to /faviconV2, plus https://trigger.dev/changelog/ as a path prefix. No wildcards — the no-wildcard beacon policy stands. The shard hosts are Google-operated with no public write path, so the enumeration is as narrow as the existing s2/favicons entry; if Google ever adds a t4, the failure mode is one broken avatar, not a broken page.

Avatar fallbackapp/components/primitives/Avatar.tsx: the image box clips, and a failed load falls back to the globe icon. That covers failures before hydration too — onError never replays for a node that already failed, so a ref checks complete && naturalWidth === 0 at attach time. The error state resets when the URL changes (key={avatar.url}).

Testing

The CSP test helper now implements CSP's real path-matching rule (trailing slash = prefix, otherwise exact, query ignored) and asserts the pins hold: the gstatic redirect target passes, beacon.png on gstatic, a t9 shard, and non-changelog trigger.dev paths stay blocked. 39 tests green plus webapp typecheck. Verified against a running webapp that the served directive contains the new sources.

@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0d92205

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4d71d2c5-3590-49e8-b109-5febdbbbc85c

📥 Commits

Reviewing files that changed from the base of the PR and between b3ceb34 and 38f367e.

📒 Files selected for processing (3)
  • apps/webapp/app/components/primitives/Avatar.tsx
  • apps/webapp/app/utils/cspImageOrigins.ts
  • apps/webapp/test/dashboardAgentImageCsp.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/webapp/app/utils/cspImageOrigins.ts
  • apps/webapp/test/dashboardAgentImageCsp.test.ts
  • apps/webapp/app/components/primitives/Avatar.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: obsmap / 🧪 Unit Tests: Observability Map
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (javascript-typescript)

Walkthrough

The webapp now handles failed avatar image loads and displays a globe fallback, including failures detected before hydration. Image CSP matching supports trailing-slash path prefixes while preserving exact matching for other paths. The default image sources include Google favicon redirect shards and the Trigger.dev changelog path. Tests cover avatar-related CSP behavior, favicon shard restrictions, changelog paths, and dashboard image directives.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the CSP and avatar overflow fixes in the webapp.
Description check ✅ Passed The description clearly explains the cause, implementation, testing, and expected behavior of the changes.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/org-avatar-csp-overflow

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.

devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +23 to +27
"https://t0.gstatic.com/faviconV2",
"https://t1.gstatic.com/faviconV2",
"https://t2.gstatic.com/faviconV2",
"https://t3.gstatic.com/faviconV2",
"https://trigger.dev/changelog/",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Release-notes entry for this server fix is missing

The user-facing release note for this webapp-only fix was deleted in the final commit (the .server-changes/org-avatar-csp.md file removed in commit 0d92205e9), so this change ships without an entry in the release notes.
Impact: Users reading the release notes will not see that broken organization avatars and changelog images were fixed.

Repository rule requiring a .server-changes note for server-only PRs

AGENTS.md and CONTRIBUTING.md both state: when a PR modifies only server components (apps/webapp/, apps/supervisor/, …) with no public package changes, a .server-changes/ markdown file must be added (frontmatter area + type, body = one plain sentence for users). This PR only touches apps/webapp/app/utils/cspImageOrigins.ts, apps/webapp/app/components/primitives/Avatar.tsx and two test files, and the previously-added note was removed by the last commit, leaving no entry.

Prompt for agents
This PR changes only apps/webapp (no packages/*), so per AGENTS.md and CONTRIBUTING.md it needs a .server-changes/ markdown file. The note that existed (.server-changes/org-avatar-csp.md, with frontmatter area: webapp / type: fix and a one-line user-facing description about org avatars and changelog images displaying again) was deleted in the final commit. Restore a .server-changes entry with user-facing wording so the fix appears in release notes.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

3 participants