Skip to content

fix(media): preserve encoded image filenames across delivery - #120119

Closed
steipete wants to merge 8 commits into
mainfrom
codex/autoqa-media-encoded-filename-owner-20260807
Closed

steipete wants to merge 8 commits into
mainfrom
codex/autoqa-media-encoded-filename-owner-20260807

Conversation

@steipete

@steipete steipete commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #120118

What Problem This Solves

Image optimization and MIME sniffing can change the encoded format without changing the public filename. A transparent WebP converted to PNG was returned and durably queued as PNG bytes with image/png while still named .webp; large QQBot image uploads then submitted that stale name to upload_prepare.

The same public metadata owner must also strip source path components even when the encoded MIME already matches the extension. Otherwise a direct Windows/local filename can leak directory information into outbound metadata.

Why This Change Was Made

The shared web-media result reconciles image leaf names with the normalized output MIME while leaving raw-loader metadata and durable artifact paths untouched. Every optimized image result—preserved or converted—passes through that public metadata owner. QQBot performs the same narrow reconciliation only at its chunked image-upload boundary, reading the bounded prefix from the already-verified descriptor so it does not reopen, rename, or replace source custody.

The split is intentional: normal direct/local/remote and queue replay paths belong to loadWebMedia; large QQBot local paths can bypass that loader, and only the chunked endpoint sends a server-visible image filename.

Production LOC: +55/-23 (net +32). Tests and test support: +320/-2 (net +318). The production growth implements the shared filename/MIME/privacy invariant plus the QQBot verified-descriptor boundary; it adds no config, protocol, dependency, storage schema, or compatibility surface.

User Impact

Converted and sniffed images now carry leaf filenames that match their encoded bytes without exposing source directories. Equivalent aliases such as .jpeg for image/jpeg, unknown image formats, non-image uploads, raw-loader metadata, and SQLite-owned spool paths remain unchanged.

Evidence

Remaining pre-land proof

  • Authenticated QQBot chunked image upload confirming the server accepts the reconciled leaf filename for the real large-image path.
  • QQBOT_APP_ID and QQBOT_CLIENT_SECRET are not exported and no matching QQBot/QQ/Tencent credential exists in the service-account-accessible Molty vault. The mandatory one-password workflow requires explicit consent before searching or using the personal 1Password account.

The final exact head is 4942a882bb5f51938f22bcc40730248ed9c17190.

AI-assisted: yes. No agent transcript is included because public transcript insertion requires separate explicit consent.

@steipete
steipete marked this pull request as ready for review August 7, 2026 02:38
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 7, 2026
@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The branch aligns public image filenames with encoded MIME types, removes source directories from image names, and applies byte-based naming to QQBot chunk uploads.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused metadata repair and regression coverage are useful, but the submitted upload scope has an acknowledged real-endpoint proof gap.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Merge readiness

⛔ Blocked before merge - 3 items remain

This PR retains useful queue-replay and filename-sanitization work beyond the merged conversion fix. Keep it open for maintainer handling; the protected label also excludes automatic cleanup.

Priority: P2
Reviewed head: 4942a882bb5f51938f22bcc40730248ed9c17190

Before merge

  • Resolve merge risk - The conflicting head has no verified combined result with current main; resolve and validate the metadata repair alongside current HEIC/HEIF byte preservation, animated WebP handling, and image limits.
  • Resolve merge risk - QQBot upload hunks target the retired bundled implementation, and authenticated endpoint acceptance remains explicitly unproven; remove them from the core landing scope and route them to the external package owner.
  • Complete next step - Resolve the conflicts as a core metadata repair, preserve current image-byte behavior, and remove the retired bundled QQBot changes. Any retained external upload change needs redacted authenticated acceptance evidence before landing.

Findings

None.

Agent review details

How this fits together

The shared media loader reads attachments, detects their format, and prepares bytes and filenames for channel delivery. The delivery queue preserves durable artifact paths, so replay must correct public metadata without changing storage custody.

flowchart TD
  A[Local or remote attachment] --> B[Shared media loader]
  B --> C[Detect and optimize image]
  C --> D[Reconcile public filename]
  C --> E[Durable queue artifact]
  E --> B
  D --> F[Channel attachment delivery]
Loading

Technical review

Best possible solution:

Use one shared public-image metadata boundary for direct loading and queue replay, preserve artifact custody and current image-byte safeguards, and keep QQBot upload policy in Tencent's package.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes a clear path: replay PNG bytes from a .webp spool artifact below preservation limits, and current main returns the stale filename. This review did not execute that path.

Is this the best way to solve the issue?

The shared metadata owner is the best repair boundary; renaming durable artifacts or adding channel-specific corrections would duplicate policy. The submitted branch needs refreshing because conversion naming already exists and QQBot now has an external owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f1c2314964b7.

Merge-risk options

Maintainer options:

  1. Narrow to the current core owner (recommended)
    Resolve the branch against current main, retain the replay and leaf-name regressions, and remove the retired bundled QQBot hunks.
  2. Pause for a coordinated external repair
    Keep landing paused while Tencent's package owner adopts and proves the chunk-upload change alongside the refreshed core repair.

Security

None.

Evidence

What I checked:

  • Pinned introduced changes: The merge-base-to-head diff changes public image metadata and QQBot upload names, with regression coverage for direct/local/remote loading, aliases, raw metadata, queue replay, and descriptor custody. It changes no storage schema, dependency declaration, config option, or authorization decision. (src/media/web-media.ts:615, 4942a882bb5f)
  • Meaningful current-main remainder: Current main corrects filenames after encoding, but its preserved-image return still uses params.fileName unchanged; the non-optimizing public path also preserves the source name. Consequently PNG bytes replayed from a .webp artifact can retain that suffix. This is source evidence, not an executed reproduction. (src/media/web-media.ts:858, f1c2314964b7)
  • Merged conversion fix: GitHub verifies fix(media): preserve correct filenames for transparent image attachments #128902 as merged at ee4bb5f. Its patch generalizes naming for encoder output, but does not reconcile preserved images or queue replay; it therefore overlaps rather than supersedes the whole branch. (src/media/web-media.ts, ee4bb5f85b56)
  • Latest-release behavior: The latest release source contains toImageFileName for encoded output while preserved and non-optimizing image results retain params.fileName. The remaining metadata defect is therefore not established as fixed in v2026.9.8. (src/media/web-media.ts:941, fc23bc864e45)
  • Queue owner and channel consumers: Queue staging allocates its artifact name before loading and writes media.buffer into that preplanned path. Telegram send-message and Discord send.shared consume the shared loader's result. Correcting public metadata at the loader boundary avoids renaming SQLite-owned artifacts or duplicating policy in these channel senders. (src/infra/outbound/delivery-queue-media-spool.ts:114, 4942a882bb5f)
  • Current preservation contract: Current tests explicitly preserve oriented JPEG bytes and a stale portrait.heif filename. Merged fix(media): preserve converted images with HEIC filenames #142263 removed the filename-based recompression veto. Conflict resolution must retain that byte-preservation behavior and explicitly reconcile the filename expectation with this repair. (src/media/web-media.test.ts:272, f1c2314964b7)

PR surface

Source +32, Tests +318. Total +350 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 55 23 +32
Tests 4 320 2 +318
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 375 25 +350

Review metrics

Metric Value Why it matters
Production versus regression coverage production +55/-23 (net +32); tests and test support +320/-2 (net +318) Production growth has a stated metadata/custody boundary justification, although the QQBot portion now belongs outside this repository.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #120118
Summary: This PR is the open candidate for the reported metadata invariant; merged work covers conversion naming but leaves preserved-image replay unresolved.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: Incorrect attachment filenames are a bounded delivery-metadata defect with useful remaining regression coverage.
  • merge-risk: 🚨 compatibility: The refreshed patch must reconcile its broader filename normalization with current preserved-image expectations and the completed QQBot ownership transition.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Shared-loader filename changes reach Telegram attachment delivery and can be observed in document filenames.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the core repair against current main and validate queue replay, MIME aliases, leaf names, HEIC/HEIF byte preservation, animated WebP, and image limits together.
  • Remove retired QQBot hunks; pursue the upload repair in Tencent's package with redacted authenticated endpoint evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-07T04:41:34.729Z sha 45a4c0d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T04:48:39.429Z sha 45a4c0d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T22:45:42.520Z sha 4942a88 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-07T23:45:34.814Z sha 4942a88 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T23:13:38.174Z sha 4942a88 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T00:58:25.924Z sha 4942a88 :: needs historical verification review before merge. :: [P1] Port the QQBot upload repair to its external package
  • reviewed 2026-09-02T16:24:46.579Z sha 4942a88 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T09:08:47.680Z sha 4942a88 :: blocked before merge. :: none

Reviewed October 3, 2026, 4:36 AM ET / 08:36 UTC (Revision 9).

@steipete
steipete force-pushed the codex/autoqa-media-encoded-filename-owner-20260807 branch from 45a4c0d to 4942a88 Compare August 7, 2026 22:38
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 7, 2026
@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 7, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Sep 2, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 18, 2026
@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Sep 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This PR has had no commits since 2026-08-07 and still has a real-endpoint proof gap for the QQBot upload path. Reopen or refresh it if the filename fix is still needed.

If this change is still needed, please open a fresh PR against current main and we'll review it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: qqbot maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Converted images retain stale filename extensions

2 participants