[Due for payment 2026-11-14] [$175] Insights - Uploaded avatars are missing from PNG exports
Reproducible in staging?: Yes, reported November 4, 2026. Reproducible in production?: Not confirmed. Issue reported by: @luacmartins, @JmillsExpensify, and @dannymcclain. Slack conversation: Avatar export investigation.
Action Performed
- Open Insights on staging with a dashboard showing members with uploaded avatars.
- Export the dashboard as a PNG.
- Open the downloaded image and check the browser console.
Expected Result
The PNG includes uploaded avatars and charts matching the dashboard, without avatar CSP violations.
Actual Result
Uploaded avatars are missing from the PNG, while default avatars render. The staging investigation identified a CSP error when fetching uploaded avatars.
Fix
The exporter fetches avatar images to embed them in the PNG. Allow https://d1wpcgnaa73g0y.cloudfront.net in the App Worker's connect-src directive, scoped to this distribution without broadening script permissions.
- Fix PR: https://github.com/Expensify/App/pull/106018
- PR-preview policy change: https://github.com/Expensify/Cloudflare-Workers/pull/276
The fix takes effect with the App Worker deployment. Verify exports on staging and production after their respective Worker deployments.
Workaround
No confirmed workaround for including uploaded avatars in the export. The dashboard remains usable.
Platforms
Web. Browser and OS were not specified in the staging report.
Screenshots/Videos
Original report with screenshot.
Related
PNG export feature: https://github.com/Expensify/App/pull/105195
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022118372058403676674
- Upwork Job ID: 2118372058403676674
- Last Price Increase: 2026-11-05
Issue Owner
Current Issue Owner: @mallenexpensify
π€ Web test steps verification results: β οΈ partial
Insights opened on dev NewDot web, but the required dashboard with uploaded member avatars was unavailable. No staging/production verification was performed; no data or source was modified.
| Step | Status |
|---|---|
1. Open Insights with uploaded member avatarsInsights displayed its empty state. The required expense/member fixture was unavailable.![]() |
β |
2. Export dashboard as PNGBlocked by the missing dashboard fixture; no export attempted. |
β |
3. Inspect PNG for avatars and chartsNot verified: no PNG exported; downloaded-image inspection was also unavailable through the tester. |
β |
4. Check console for avatar CSP violationsNot verified: browser console access was unavailable through the tester. |
β |
Proposal
What is the root cause of that problem?
Confidence: medium β code supports the reported staging diagnosis; end-to-end confirmation remains outstanding.
The dashboard can display uploaded avatars, but PNG export separately fetches their bytes for embedding. The App Worker's connect-src omits the reported CloudFront distribution, even though img-src permits displaying it. Failed image fetches can become transparent placeholders, explaining a downloaded PNG with missing uploaded avatars while locally rendered default avatars remain visible.
Code evidence and alternatives checked
- The exporter captures the DOM through
modern-screenshot: exportInsightsDashboard/index.ts:19β46. - The library fetches remote images for embedding and substitutes a placeholder on image-fetch failure: embed-image-element.ts:9β25, fetch.ts:120β131.
- The inspected policy permits image display but lacks the avatar origin in connection permissions: csp.ts:70β135. Default/catalog avatars resolve locally: UserAvatarUtils.ts:402β422.
- CORS or rendering problems could coexist, but do not explain the reported CSP refusal. Allowing the connection does not itself prove CDN responses permit cross-origin reads. Backend logs would not establish this browser-side failure.
What changes do you think we should make in order to solve the problem?
Use the existing open Allow avatar fetches for Insights PNG exports PR rather than creating a duplicate. It adds only https://d1wpcgnaa73g0y.cloudfront.net to connect-src, with staging/production policy regression tests; it does not broaden script permissions.
Fix scope and acceptance checks
- Proposed permission: csp.ts:94β95. Proposed header tests: csp.test.ts:7β41. These were inspected, not executed in this analysis.
- Deploy the App Worker, reload the document, then verify a populated dashboard's exported PNG includes uploaded avatars and charts without avatar CSP violations. Repeat on staging and production after their respective deployments; production impact is currently unconfirmed.
- If fetching still fails after CSP permits it, inspect CDN CORS headers and redirects.
- Correct the PR's offline expectation: an uncached avatar-fetch failure alone can produce a transparent placeholder rather than the generic error dialog.
- The issue's separately linked PR-preview policy change was not independently inspected.
What alternative solutions did you explore? (Optional)
Changing img-src, broadening CloudFront permissions, or allowing scripts would not address the narrowly identified connection restriction safely. No exporter rewrite is indicated by the evidence.
Possibly related: Insight-new console errors appear after restore the encoder and export again concerns the same export flow, but its reported console errors are not established as the same cause or a duplicate.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106119#issuecomment-6662620193) to create a draft PR. An existing fix PR is already open; prefer reviewing it rather than requesting a duplicate.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal. Β· view recording
Triggered auto assignment to Contributor-plus team member for initial proposal review - @truph01 (External)
Job added to Upwork: https://www.upwork.com/jobs/~022118372058403676674
Proposal
Please re-state the problem that we are trying to solve in this issue.
The reported fault is the connect-src configuration in web/cloudflare-worker/src/csp.ts:70β135; the exact declaration and faulty line have not been independently verified. Staging PNG exports omit uploaded avatars; production impact is unconfirmed.
What is the root cause of that problem?
β οΈ Why MelvinBot's proposal is insufficient / introduces regressions:
- Its missing dashboard fixture prevented export verification. This limits its evidence; it does not invalidate its diagnosis.
The supplied investigation identifies a CSP refusal when the exporter fetches uploaded-avatar bytes. Display permission under img-src does not authorize that fetch. The supplied snippets concern unrelated modules and cannot substantiate an exact function or patch.
What changes do you think we should make in order to solve the problem?
Review the existing fix PR first; the supplied evidence does not justify a competing implementation.
The intended change is one source entry inside the existing connect-src list:
'https://d1wpcgnaa73g0y.cloudfront.net',
An exact executable diff requires inspecting the surrounding declaration. Do not fabricate additional changes to meet a line quota. Keep script permissions unchanged.
Compare branch: https://github.com/Expensify/App/compare/main...camesenin:App:fix-issue-106119?expand=1
This requested compare URL has not been verified.
What alternative solutions did you explore? (Optional)
Changing img-src would target the wrong directive. Wildcard CloudFront permissions unnecessarily broaden access. MelvinBot already recommends the same narrow fix.
What automated tests can you add to prevent this from re-occurring?
Extend web/cloudflare-worker/tests/csp.test.ts to assert the exact origin in staging/production connect-src, with no wildcard or script-policy expansion. Tests and populated-dashboard exports must be verified after Worker deployment; neither was executed here.
Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01b60d704ba377be83
β Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
Please re-state the problem that we are trying to solve in this issue
When an Insights dashboard containing members with uploaded avatars is exported as a PNG, the uploaded avatars are missing from the downloaded image (default/letter avatars render fine). The staging investigation flagged a CSP error: the PNG exporter fetches the remote avatar bytes to embed them, but the avatar CDN origin is not permitted by the App Worker's connect-src.
What is the root cause of that problem?
Two layers, both in src/pages/Insights/exportInsightsDashboard/index.ts:
Layer 1 β the exporter only pre-rasterizes <canvas> charts, never avatar <img>s (lines 30β38)
Before calling domToCanvas, the export pre-converts chart canvases to inline data URLs so the clone is self-contained:
// src/pages/Insights/exportInsightsDashboard/index.ts:30-38
const chartImages = elements.map((element) =>
Array.from(element.querySelectorAll('canvas, img'), (canvas) => {
if (!(canvas instanceof HTMLCanvasElement)) { // <-- only canvases handled
return undefined; // <-- avatars (HTMLImageElement) fall through
}
const {width, height} = canvas.getBoundingClientRect();
return {src: canvas.toDataURL('image/png'), width, height};
}),
);
The querySelectorAll('canvas, img') does collect avatar <img> elements (the comment at line 50 even says "Count avatars too so chart indices stay aligned"), but the guard on line 32 maps every non-<canvas> node to undefined. So in onCloneNode (lines 50β67) the loop skips them (if (!chartImage) continue;, line 53) and the cloned avatar <img> keeps its original remote src.
Layer 2 β domToCanvas (modern-screenshot) then tries to fetch that remote src and is blocked by connect-src
Because the avatar <img> in the clone still points at its remote URL (e.g. https://d1wpcgnaa73g0y.cloudfront.net/β¦), the modern-screenshot rasterizer has to fetch() the bytes to embed them (embed-image-element.ts in the library fetches remote image srcs and substitutes a transparent placeholder on failure). That fetch() is governed by connect-src, not img-src. The App Worker CSP (web/cloudflare-worker/src/csp.ts:70β135) lists img-src: ['*', β¦] (so the avatar displays on screen) but connect-src does not include https://d1wpcgnaa73g0y.cloudfront.net β so the embed-time fetch fails, the avatar becomes a transparent placeholder, and the exported PNG is missing it.
This is why uploaded avatars (remote CloudFront URL β AvatarImage renders <Image source={{uri: β¦}}> β web <img> with remote src, per src/components/Avatar/primitives/AvatarImage.tsx:38 and src/components/Avatar/UserAvatar.tsx:77) fail, while default avatars render: defaults are returned as local SVG components by getAvatar (src/libs/UserAvatarUtils.ts:412β423) and inline in the DOM, needing no fetch. The Insights dashboard uses exactly this <UserAvatar source={item.avatar} /> in src/pages/Insights/charts/InsightsDataTable.tsx:90β93.
The existing fix PR #106018 addresses only Layer 2 (adding the CloudFront origin to connect-src). That unblocks the fetch for this one CDN, but leaves the exporter dependent on (a) the third-party library's fetch path and (b) every future avatar/CDN origin also being added to CSP. The robust fix addresses Layer 1: pre-rasterize the avatar <img> to a data URL the same way canvases already are, so no runtime fetch β and therefore no CSP dependency β is needed at all.
What changes do you think we should make in order to solve the problem?
Primary (Layer 1): pre-embed avatar <img> elements as data URLs before domToCanvas. In exportInsightsDashboard/index.ts, extend the chartImages capture so HTMLImageElement nodes that are remote (and already loaded) are rasterized to a data URL via a canvas, exactly parallel to the canvas path:
// Replace the chartImages builder (lines 30-38) with one that also handles <img>:
const chartImages = elements.map((element) =>
Array.from(element.querySelectorAll('canvas, img'), (node) => {
if (node instanceof HTMLCanvasElement) {
const {width, height} = node.getBoundingClientRect();
return {src: node.toDataURL('image/png'), width, height};
}
if (node instanceof HTMLImageElement) {
const {width, height} = node.getBoundingClientRect();
// Cross-origin <img> can't be drawn straight to a canvas without CORS taint;
// re-fetch the bytes (same-origin-ish via the CDN) and convert to a data URL.
// If anything fails, leave undefined and let the CSP/fetch path handle it.
try {
// Prefer the already-cached bitmap if the image loaded cleanly and same-origin permits.
const c = document.createElement('canvas');
c.width = node.naturalWidth || width || 1;
c.height = node.naturalHeight || height || 1;
const ctx = c.getContext('2d');
if (!ctx) return undefined;
ctx.drawImage(node, 0, 0, c.width, c.height);
return {src: c.toDataURL('image/png'), width, height};
} catch {
// Canvas tainted (cross-origin without CORS) β fall back to fetch+data URL below, or undefined.
return undefined;
}
}
return undefined;
}),
);
Then in onCloneNode, the existing replacement loop (lines 52β67) already swaps each captured node by index β so once the undefined for avatars is replaced with a real data URL, the cloned <img> gets src = "data:image/png;base64,β¦", which domToCanvas embeds with no fetch and no CSP dependency. (For the cross-origin/tainted case, fall back to a fetch(src).then(r => r.blob()) β FileReader β data URL; this still needs connect-src, so the CSP addition from #106018 is kept as the fallback, not the primary path.)
Secondary (Layer 2, keep PR #106018): add https://d1wpcgnaa73g0y.cloudfront.net to connect-src in web/cloudflare-worker/src/csp.ts and extend web/cloudflare-worker/tests/csp.test.ts to assert it for staging/production. This covers the fetch-fallback for tainted canvases and any other in-DOM remote images, and matches the issue's stated fix.
Net effect: avatars embed even if the CDN URL changes or a new avatar origin is used, and the CSP change closes the remaining cross-origin fetch gap.
What specific scenarios should be covered by automated tests?
tests/unit/exportInsightsDashboard*:- Given a dashboard DOM with one
<canvas>chart + one<img>avatar (remotesrc), after capture the avatar's cloned node has adata:image/pngsrc(no network fetch in the embed path). - An avatar
<img>whose draw-to-canvas throws (tainted) falls back to the fetchβdata-URL path and, with CSP permitting, still embeds; without CSP it degrades to the placeholder (assert the fallback is reachable, not silent). - Default (SVG) avatars still embed unchanged.
- Given a dashboard DOM with one
web/cloudflare-worker/tests/csp.test.ts: staging + productionconnect-srccontainshttps://d1wpcgnaa73g0y.cloudfront.netwith no wildcard/script broadening.- Manual/staging: export a populated dashboard with uploaded avatars; assert the PNG contains them and the console shows no CSP violations.
What alternative solutions did you explore? (Optional)
- CSP-only fix (PR #106018 as the whole answer). Necessary but insufficient: it fixes today's CDN but couples every avatar-host change to a CSP deploy, and still routes every export through a runtime cross-origin fetch that can race/taint. Pre-embedding removes the fetch entirely.
- Configure the avatar CDN to send
Access-Control-Allow-Originand setcrossOrigin="anonymous"on<img>. Would avoid canvas taint, but requires backend/CDN config changes and touches the avatar render path outside the export scope. Good long-term companion to the primary fix. - Replace
modern-screenshot's embed with a custom rasterizer. Over-engineered; pre-embedding the<img>nodes reuses the library for everything else.
PR
PR will be linked here once created.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01b6a593fd295a20bf
β Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
Please re-state the problem that we are trying to solve in this issue.
When exporting an Insights chart/table view as a PNG on Web (or Desktop), users who have custom uploaded profile avatars appear with blank/missing avatars in the downloaded PNG image (and browser console logs CORS / CSP fetch errors), whereas users with default SVG avatars render properly.
What is the root cause of that problem?
When generating the PNG export via html-to-image (toPng / toBlob), html-to-image clones the DOM node and attempts to fetch every external <img> src via window.fetch so it can inline the image as a data: URI inside the SVG <foreignObject> before drawing to <canvas>. Custom uploaded avatars are served from CloudFront / S3 (*.cloudfront.net or Expensify CDN) without crossOrigin="anonymous" / permissive CORS headers on unauthenticated fetch calls (or violate connect-src in the app's Content Security Policy when html-to-image calls fetch() on the avatar URL). As a result, html-to-image's fetch rejects, leaving the <img> blank in the exported PNG. Default avatars work because they are rendered as inline <svg> elements rather than external <img> URLs.
What changes do you think we should make in order to solve the problem?
- In the Insights PNG export utility (where
toPng/toBlobfromhtml-to-imageis invoked) and/or insrc/components/Avatar.tsx/Imagewhen rendering inside an exportable container:- Pass an image placeholder / pre-inlining step before calling
toPng, or convert external avatar<img>elements that cannot be fetched via CORS into inline fallback initials/default SVG avatars (or pre-fetch them through the authenticated image loader / proxy withcacheBust: trueandcrossOrigin="anonymous").
- Pass an image placeholder / pre-inlining step before calling
- Add a
filterorimagePlaceholderhandling in thetoPngoptions so that if an external avatar URL cannot be inlined due to CORS/CSP, the export gracefully renders the user's fallback SVG avatar rather than failing with CSP errors and leaving an empty circle.
What alternative solutions did you explore? (Optional)
We considered adding *.cloudfront.net to connect-src in index.html alone, but even if CSP permits fetch(), S3/CloudFront responses cached by the browser from a non-CORS <img> request will still fail a subsequent CORS fetch() in Chromium unless crossOrigin="anonymous" (with cache-busting) or a fallback SVG avatar is used during export.
π£ @jeffrey-graham! π£ Hey, it seems we donβt have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
@truph01
The solution for this issue has been :rocket: deployed to production :rocket: in version 9.5.33-1 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/106018
If no regressions arise, payment will be issued on 2026-11-14. :confetti_ball:
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
@truph01 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@truph01 Eep! 4 days overdue now. Issues have feelings too...
Triggered auto assignment to @mallenexpensify (Awaiting Payment)
Payment Summary
Resolving PRs:
-
https://github.com/Expensify/App/pull/106018
-
Reviewer: @truph01 owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
- [ ] I have confirmed assignees, roles, and Upwork contracts look correct
- [ ] I have paid out Upwork contracts / manual NewDot requests
- [ ] [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
Claude posting on behalf of Matt:
Hold/$0. Job price: $175 (standard, no Help Wanted, assigned 2026-11-05).
- truph01 (C+): 0%, did not review PR 106018
luacmartins (employee) wrote PR 106018. Three employees approved it. truph01 has no comment on the issue or the PR.
Next: confirm 0%, then close.
Evidence
- Resolving PR 106018: "[No QA] Allow avatar fetches for Insights PNG exports on dev", merged 2026-11-05, approved by AndrewGable, justinpersaud and roryabraham. No revert.
- No C+ checklist on the issue.
PAYPREP v1
Closing, @truph01 didn't review the PR