fix(media-core): detect MIME from encoded URL extensions#102649
fix(media-core): detect MIME from encoded URL extensions#102649VectorPeak wants to merge 10 commits into
Conversation
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
|
Codex review: needs maintainer review before merge. Reviewed July 9, 2026, 9:19 AM ET / 13:19 UTC. Summary PR surface: Source +7, Tests +18. Total +25 across 2 files. Reproducibility: yes. at source level: current main passes URL.pathname directly to path.extname, and a focused Node URL/path probe shows percent-encoded extension dots remain encoded and do not map to .mp4. An active non-Discord product path remains unproven. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Settle the shared media-core contract with maintainer-visible non-Discord call-chain evidence, then either land this focused helper fix with agreed separator semantics or leave the shared helper unchanged and rely on owner-local fixes like #101815. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main passes URL.pathname directly to path.extname, and a focused Node URL/path probe shows percent-encoded extension dots remain encoded and do not map to .mp4. An active non-Discord product path remains unproven. Is this the best way to solve the issue? Unclear as a merge decision: final-segment decoding is the narrow plausible helper shape, but maintainer feedback says the shared media-core fix still needs active non-Discord repro and separator-contract acceptance. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3fd52514e35f. Label changesLabel justifications:
Evidence reviewedPR surface: Source +7, Tests +18. Total +25 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (5 earlier review cycles)
|
Decode only the final HTTP(S) URL pathname segment before extension lookup so malformed earlier segments do not block encoded filename extensions. Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
|
Updated the branch and PR evidence for ClawSweeper's P1/P2 asks:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Lock in final-segment URL filename decoding behavior for uppercase encoded extensions, encoded slash filenames, and encoded separator suffixes. Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
|
Added the extra URL filename edge coverage from the patch audit:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
This is not landable as written. The underlying
A viable shared fix needs an active non-Discord repro, final-component-only decoding that preserves encoded separators, and edge coverage for malformed earlier/final escapes, encoded separators, queries/fragments, and POSIX/Windows behavior. This also needs to clear the batch's non-triviality bar rather than landing as an eight-line speculative public-helper change. |
|
@vincentkoc Thanks. I will try it. |
|
@vincentkoc Thanks for the review. I’ll take another look at the real call chain for this media-core fallback. If I can’t find enough real call-chain evidence to show that this is reachable and useful in practice, I’ll close the PR rather than keep pushing a weak case. Thanks again for the detailed feedback. |
Preserve encoded slash and backslash bytes while decoding URL filename extensions, and cover the active media-understanding runtime classification path for encoded video URLs. Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
|
@vincentkoc I followed up on each point from your review on the latest head (
Validation on this exact head:
Could you please take another look? If this active runtime call-chain evidence still does not meet the bar for a shared helper change, I will close the PR as previously promised rather than expand the patch further. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@vincentkoc Follow-up on the latest head (
Validation on this exact head:
Could you please re-review this version? If the paired CLI-entry and runtime-classification proof still does not meet the bar for an active shared caller, I will close the PR rather than broaden the patch further. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Fixed and landed via #103410 as GitHub rejected the maintainer rebase/push because the generated The replacement passed 246 focused tests, the changed gate, exact-head CI, and a real loopback before/after check. Thank you, @VectorPeak, for finding and fixing this. Closing this original PR as superseded by the landed replacement. |
Fixes encoded HTTP(S) media URLs such as
render%2Emp4being treated as unknown by the media-core MIME fallback.What Problem This Solves
new URL(...).pathnamekeeps percent-encoded filename bytes. On currentmain,getFileExtension()passes that pathname directly topath.extname(), so URLs such asrender%2Emp4andclip%2Ewebmdo not expose a recognized extension.This is reachable outside Discord. The capability CLI accepts a remote media path and passes it as
filePath/mediaUrltodescribeImageFile(). That entersrunMediaUnderstandingFile()andbuildFileContext(), wheremimeTypeFromFilePath(remoteRef)determines the attachmentMediaType. Without this fix, an encoded video URL requested through the image capability falls back toimage/*; with the fix it remainsvideo/mp4.Why This Change Was Made
The URL branch now:
/;/and\bytes (%2F/%5C) literal while decoding the rest of the filename, so object-key data cannot become a path boundary;path.posix.extname()for URL filename parsing, making URL semantics independent of the host OS;Local filesystem path behavior is unchanged. The change does not decode the full pathname, parse
Content-Disposition, or infer a MIME type when encoded data appears after an otherwise valid extension.User Impact
Supported encoded URL filenames now follow the same MIME fallback as their decoded equivalents:
Encoded separators remain filename data rather than becoming path separators:
Evidence
Active non-Discord call chain:
The evidence covers adjacent product layers without depending on network or provider execution:
capability image describecommand withhttps://cdn.example.com/clip%2Emp4?download=1#previewand verifies that the real CLI entry preserves it as bothfilePathandmediaUrl.describeImageFile()and executes the realrunMediaUnderstandingFile()/buildFileContext()path.normalizeMediaAttachments()and provider execution are mocked boundaries; the test verifies that the computedMediaType: video/mp4is passed into normalization and the capability context.Direct helper contract tests additionally verify that
%2F/%5Cremain literal extension content, malformed final encoding falls back to the raw filename, and a trailing slash leaves the final URL component empty.Focused helper proof after the fix:
Validation
Exact-head CI for
e6368176completed with no failures, including successfulReal behavior proofruns.