Skip to content

Conversation

@javirln
Copy link
Member

@javirln javirln commented Nov 28, 2025

Fixed a bug in loadPolicyScript and loadLegacyPolicyScript functions where the source.path field was always treated as a file path, even when it contained an HTTP or HTTPS URL.

According to the protobuf definition, the path field can be a URI reference, but the code was incorrectly using filepath.Join on all paths, which corrupted URLs by treating them as relative file paths.

Changes

  • Added isURLPath helper function to detect HTTP/HTTPS URLs using the existing RefParts utility
  • Updated loadPolicyScript to handle URLs directly without path joining
  • Updated loadLegacyPolicyScript with the same fix for backward compatibility
  • Added test coverage for URL detection logic

The fix maintains backward compatibility with relative and absolute file paths while properly handling remote policy references via HTTP/HTTPS.

Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
@javirln javirln self-assigned this Nov 28, 2025
@javirln javirln changed the title fix(policy): Make http loader work on policy develop eval fix(policy): Fix policy script loading for HTTP/HTTPS URLs Nov 28, 2025
@javirln javirln added hotfix and removed hotfix labels Nov 28, 2025
@javirln javirln enabled auto-merge (squash) November 28, 2025 11:53
@javirln javirln merged commit 37f3182 into chainloop-dev:main Nov 28, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants