Skip to content

Fall back to the raw path when strict mode rejects an already-resolved entrypoint - #265

Open
Amoifr wants to merge 1 commit into
symfony:2.xfrom
Amoifr:fix-230-strict-mode-manifest
Open

Fall back to the raw path when strict mode rejects an already-resolved entrypoint#265
Amoifr wants to merge 1 commit into
symfony:2.xfrom
Amoifr:fix-230-strict-mode-manifest

Conversation

@Amoifr

@Amoifr Amoifr commented Jul 21, 2026

Copy link
Copy Markdown
Q A
Bug fix? yes
New feature? no
Issues Fix #230
License MIT

entrypoints.json already stores the final public paths of the built assets, but TagRenderer passes each one back through packages->getUrl(). When the default asset package is backed by the JSON manifest (framework.assets.json_manifest_path) with framework.assets.strict_mode: true, the strategy treats the already-resolved path as a manifest key, fails to find it and throws AssetNotFoundException, so encore_entry_link_tags() / encore_entry_script_tags() blow up. With strict_mode: false the same call silently returns the path unchanged, which is why the bug only shows up in strict mode (reported by @bmorg, kept open by @Kocal).

I reproduced it against the real asset component: getUrl('/web-subfolder/app.b75294ae.css') throws in strict mode, while getUrl('my-prefix/app.css') (the manifest key) resolves fine.

This catches AssetNotFoundException in getAssetPath() and falls back to the raw path, which is already the correct, final one, matching what strict_mode: false does today. Real asset() calls elsewhere keep their strict-mode behavior untouched. I deliberately kept the getUrl() call rather than removing it (as the issue suggested), since it is what applies a base path / CDN to the entrypoint values.

@Kocal, since this touches the entrypoints / manifest / base-path interaction, I went for the smallest safe fix but I'm happy to adjust the direction if you had something else in mind.

Thanks a lot for the bundle! 🙏

@carsonbot carsonbot added Bug Bug Fix Status: Needs Review Needs to be reviewed labels Jul 21, 2026
@Amoifr
Amoifr force-pushed the fix-230-strict-mode-manifest branch 2 times, most recently from f2b2886 to cbbe866 Compare July 21, 2026 16:05
@Amoifr
Amoifr force-pushed the fix-230-strict-mode-manifest branch from cbbe866 to 89da581 Compare July 21, 2026 16:23
@Amoifr

Amoifr commented Jul 21, 2026

Copy link
Copy Markdown
Author

Heads-up on the red Fabbot check: it is a false positive coming from two of its steps disagreeing with each other. Check PHP code style wants a : void return type on the test methods, while Check test-case methods forbids it ("Test case methods should not have a return type"), so both cannot be satisfied at once.

I went without the return type, which matches every existing test method in the suite and the Check test-case methods convention. All the blocking checks (tests on 8.1 to 8.5, PHPStan, Psalm, Composer Normalize) are green. Happy to flip it the other way if you prefer. 🍒

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

Labels

Bug Bug Fix Status: Needs Review Needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

encore_entry_link_tags incorrectly querying manifest.json

2 participants