ArtifactNormalizer: reaching max_files drops media still within max_media_files

Open
#6,325 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start by locating ArtifactNormalizer and the loop that applies max_files and max_media_files; trace how sourceFilesBeforeGeneratedExpansions orders files before the cutoff. Use the SSI direct-artifact import scenario in the issue to check the behavior. Done means media files are admitted up to max_media_files after the non-media limit is reached, and every omitted file is still reported.

Written by the indexing model from the issue text.

Description

Problem

ArtifactNormalizer enforces two separate limits: max_files for non-media files and max_media_files for media. When a non-media file reaches max_files, the loop breaks. Every remaining raw file is omitted, including media files that are still within the max_media_files budget.

Inline style and script expansion (withInlineStyleFiles, withInlineScriptFiles, contentAddressInlineFiles) adds generated non-media files. sourceFilesBeforeGeneratedExpansions moves those generated files after the source files, but media files later in the list still fall behind the cutoff.

Evidence

Site: lloydlofthouse.com (Blogger). SSI direct-artifact import, which carries compiler_limits.max_files = 67; the artifact has 118 files.

  • The compile records file_limit_exceeded for 20 files, including website/media/Promotion-Cover-*.jpg and website/media/mqdefault.jpg.
  • Those images are referenced only by related-post cards. They resolve through MissingMediaRecovery to the placeholder token asset-667e3e6f8f8bfd37. They never reach the theme or uploads in the Studio import.
  • With #6315 (related-card featured images), 8 of 12 card posts get that placeholder token. resolveFeaturedImageTargets then drops their featured images, so those posts import without thumbnails.

Expected

Reaching the non-media max_files limit only stops non-media files. Media files keep being admitted up to max_media_files, and each dropped file is still reported.


AI disclosure: Claude (Anthropic) via Pi/Roadie in Franklin's workspace traced this with instrumented compiles of the SSI artifact and wrote this issue. Chris directed the work.

Dominant language
PHP
Stars
28
Forks
5
Avg merge
2h 59m
Merged PRs (30d)
942

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/blocks-engine

All issues in Automattic/blocks-engine

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.