Skip to content

Fix screenshot images failing with RustFS presign host mismatch - #334

Merged
mxschmitt merged 1 commit into
mainfrom
cursor/fix-file-uploads-host-67ec
Sep 4, 2026
Merged

Fix screenshot images failing with RustFS presign host mismatch#334
mxschmitt merged 1 commit into
mainfrom
cursor/fix-file-uploads-host-67ec

Conversation

@mxschmitt

@mxschmitt mxschmitt commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Problem

Running snippets (including ?e=crawl-y-combinator) stored screenshots in RustFS and returned a SigV4 presigned GET. Those URLs are signed for the in-cluster Host rustfs:9000 (X-Amz-SignedHeaders=host), then shown as https://try.playwright.tech/file-uploads/{uuid}.png?....

Opening that URL fails (host / signature mismatch; production Cloudflare often surfaces this as a 502). The <img> in the output panel stays broken.

minio-go is still the right S3 client for talking to RustFS. The bug is using presigned URLs whose signed Host cannot match every public hostname (prod, localhost NodePort, etc.). RUSTFS_SERVER_DOMAINS is for virtual-host S3 (bucket.example.com), not same-origin path-style /file-uploads/ on the app host.

Fix

Serve downloads through file-service (same pattern as /service/control), keep RustFS cluster-internal:

  • On upload, return a host-relative /file-uploads/{uuid}.ext with no presign query.
  • file-service streams the object from RustFS on GET/HEAD.
  • Caddy and the ingress send /file-uploads/ to file:8080 instead of proxying browsers to RustFS.

Verification

  • go test ./...
  • S3_ENDPOINT=127.0.0.1:9000 ... go test ./file-service/ -v against k3s RustFS
  • k3s: run crawl-y-combinator; publicURL is /file-uploads/{uuid}.png (no query)
  • GET that path with Host: try.playwright.tech via Caddy and via Traefik ingress → 200 image/png
  • Browser: PNG renders; /?e=crawl-y-combinator loads the example
Open in Web Open in Cursor 

Presigned GETs were signed for the in-cluster rustfs:9000 Host. Browsers
request try.playwright.tech/file-uploads/..., so SigV4 verification fails
(host mismatch / SignatureDoesNotMatch) and screenshots do not render.

Return a host-relative /file-uploads/{uuid} URL and stream objects from
file-service. Caddy and ingress proxy that path to file, not rustfs.

Co-authored-by: Max Schmitt <max@schmitt.mx>
@mxschmitt
mxschmitt marked this pull request as ready for review September 4, 2026 19:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 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-04T19:05:40.055708Z 630d164 Draft marked ready
ℹ️ 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.

@mxschmitt
mxschmitt merged commit 08a1bd5 into main Sep 4, 2026
11 checks passed
@mxschmitt
mxschmitt deleted the cursor/fix-file-uploads-host-67ec branch September 4, 2026 19:05

@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: 630d164979

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

Comment thread file-service/main.go
}

// objectNameRe matches UUID object keys written by processUploadedFile.
var objectNameRe = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.(png|pdf|webm|zip)$`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept every object name generated during upload

When an allowed payload uses a filename such as result.PNG, or a PNG explicitly written without a .png suffix, processUploadedFile still stores it and returns 201 because validation is MIME-based, but the returned URL always receives 400 here because this regex accepts only four lowercase suffixes. Derive the object suffix from the validated MIME type, or reject unsupported filename extensions before storing and returning an unusable files[].publicURL.

AGENTS.md reference: AGENTS.md:L108-L108

Useful? React with 👍 / 👎.

cursor Bot pushed a commit that referenced this pull request Sep 4, 2026
#334 moved /file-uploads GET from RustFS to file-service, but
upgrade_k3s_containers.sh pulled frontend:latest and explicitly skipped
file. Production Caddy now proxies screenshots to file:8080 while the
file pod still has no download handler, so every image 404s.

Pull file-service:latest, restart deployment/file, and re-exec the repo
script after reset so this list is used on the same deploy cycle.

Co-authored-by: Max Schmitt <max@schmitt.mx>
mxschmitt added a commit that referenced this pull request Sep 4, 2026
#334 moved /file-uploads GET from RustFS to file-service, but
upgrade_k3s_containers.sh pulled frontend:latest and explicitly skipped
file. Production Caddy now proxies screenshots to file:8080 while the
file pod still has no download handler, so every image 404s.

Pull file-service:latest, restart deployment/file, and re-exec the repo
script after reset so this list is used on the same deploy cycle.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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