Allow ?nocache only for http url artifacts
#1487
Merged
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.
Restrict Dependency Cache Busting to HTTP/HTTPS URLs Only
Problem
The
?nocachecache-busting feature is being applied to all URL-based dependencies, including S3 URLs. This causes issues when the dependency URLs are passed to Spark viaspark.jars, as Spark attempts to download URLs like:S3 (and other non-HTTP protocols) don't support the
?nocachequery parameter, leading to errors when Spark tries to resolve these dependencies.Root Cause
When a user disables caching for a dependency, the frontend appends
?nocacheas a sentinel value to the dependency string. This was originally designed for HTTP-based artifact servers (Artifactory, Nexus) where the same URL can point to different file versions during development. However, the implementation didn't restrict this to HTTP/HTTPS URLs only, allowing it to be applied to S3, file://, and other protocols where it's invalid.The
?nocachesuffix propagates through the system:?nocacheto the dependency string?nocacheis passed to Spark viaspark.jars?nocachemakes the URL invalidSolution
Changes Made
Frontend UI (
notebookconfig.ts):isHttpUrl()private method to theDependenciesclass to check if a dependency is an HTTP/HTTPS URL...) button for non-HTTP URLs (S3, file://, etc.)?nocachefor HTTP/HTTPS URLs and pip dependencies in theconfgetterBehavior:
?nocachenever added?nocachenever added?nocachenever addedWhy This Approach?
This solution prevents the problem at the source rather than stripping
?nocachein the backend:Technical Details
The check uses JavaScript's
URLconstructor to parse the dependency string:This safely handles:
truefalsefalse(caught by exception)Testing
Manual Testing Steps
Build and run Polynote:
Create a new notebook and open Configuration → Dependencies
Test S3 URL (cache option should be hidden):
...button is not visible.ipynbfile - no?nocacheappendedTest HTTP URL (cache option should be visible):
...button is visible.ipynbfile -?nocacheis appendedTest pip dependency (cache option should be visible):
piptype...button is visibleTest Maven coordinates (cache option should be hidden):
...button is not visibleExpected Behavior
?nocacheAdded?Backward Compatibility
?nocachecontinue to work?nocache) continue to work?nocache(invalid state), they will be saved without?nocacheon next saveEffect
When url is http, there would be option to select cache or no cache.
For non-http url, there would be no option to do so.