fix: only use a token file from a jar when it is from a production build - #25682
Draft
totally-not-ai[bot] wants to merge 3 commits into
Draft
fix: only use a token file from a jar when it is from a production build#25682totally-not-ai[bot] wants to merge 3 commits into
totally-not-ai[bot] wants to merge 3 commits into
Conversation
When no flow-build-info.json is found outside a jar, the lookup falls back to a copy inside one. A copy packaged into a dependency by mistake is written by prepare-frontend, so it carries the folders and the Node version of the machine that built the dependency, and the application fails to start with a folder it has never heard of. Adds a failing test for that case and one that keeps the packaged application case, where the token file of the application itself is inside a jar, working.
The flow-build-info.json lookup skips copies inside jars and falls back to one only when the application has none of its own, which is the case for a packaged application. A copy that a dependency packages by mistake was then used as well, and as prepare-frontend writes it, it brought the project folders and the Node version of the machine that built the dependency, failing the startup with a folder that does not exist. A file from a jar is now used only when it declares production mode, which a packaged application always does and a file left over from a development build never does. The ignored file is named in a warning so that the mistake in the dependency can be fixed.
The warning about not being able to tell which flow-build-info.json is the right one was left out whenever the application looked packaged into a jar, even when the file was not the one the rule for a packaged application points at, which is when knowing about the other candidates helps the most. The warning is now left out only when the file is the one in the outermost jar, and the cases with more than one file inside a jar are covered by tests.
Contributor
Author
Type of change
How to test
Test coverageIn
The tests that read the file from the class path now use a plain class API changesNone. Note #25681 touches the same method, and makes the counting of nested |
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
When Flow cannot find
flow-build-info.jsonoutside a jar, it falls back to a copy inside one. If a dependency packaged such a file by mistake, that file was used and it carried the folders and Node version of the machine that built the dependency, so the application failed to start. Flow now accepts a file from a jar only when it says production mode.What changed
Behavior change: a
flow-build-info.jsonfound inside a jar is now used only if it setsproductionMode: true. This affects only applications where the token file comes from a jar. A packaged (production) application always writes production mode, so it keeps working. A leftover development-mode file inside a dependency is now skipped, and a warning names the file so the dependency can be fixed. If no usable file is left, the lookup returns nothing and the application starts with its defaults instead of with another project's settings.Other changes in
DefaultApplicationConfigurationFactory:jar!/in the path (the application's own jar) are tried first, then the rest.No public or protected API changed.
Test summary
npmFolderand Node version do not reach the configurationDefaultApplicationConfigurationFactoryTest.create_onlyDevelopmentModeTokenFileInsideJar_tokenFileIsIgnored→ 1DefaultApplicationConfigurationFactoryTest.create_productionModeTokenFileInsideJar_tokenFileIsUsed→ 2DefaultApplicationConfigurationFactoryTest.create_developmentModeTokenFileInsideJarIsFoundFirst_productionModeOneIsUsed→ 3DefaultApplicationConfigurationFactoryTest.create_packagedApplicationWithNestedJars_tokenFileOfTheApplicationIsUsed→ 4DefaultApplicationConfigurationFactoryTest.create_unparseableTokenFileInsideJar_tokenFileIsIgnored→ 5Left untested on purpose: the exact wording of the log messages, and the test helpers (
mockJarTokenFile,mockTokenFileUrl), which only build URLs used by the tests above.