Skip to content

fix(path): sanitize cache path host and improve cross-platform path handling - #722

Open
reginaldalfret wants to merge 2 commits into
Boeing:mainfrom
reginaldalfret:fix/cross-platform-path-handling
Open

reginaldalfret wants to merge 2 commits into
Boeing:mainfrom
reginaldalfret:fix/cross-platform-path-handling

Conversation

@reginaldalfret

Copy link
Copy Markdown

Description

This pull request addresses cross-platform path handling issues affecting schema cache storage and path resolution on Windows systems.

Summary of Changes

  1. Schema Store Cache Path:
    • In pkg/schemastore/schemastore.go, sanitized colons (:) in parsed.Host within cachePathForURL to prevent Windows filesystem errors when caching schemas from URLs containing port numbers (e.g., http://127.0.0.1:8080/schema.json). On Windows, : is an invalid filename/directory character.
  2. Justfile Import Path Resolution:
    • In pkg/validator/justfile/gojust.go, enhanced resolveImportPath to recognize leading forward and backward slashes as rooted paths on Windows (where filepath.IsAbs returns false for volume-less rooted paths such as /path/to/import.just), preventing incorrect prepending of the parent directory.
  3. Cross-Platform Test Reliability:
    • Replaced hardcoded POSIX / separators in schemastore_test.go and resolve_test.go with filepath.Join to match platform-specific paths.
    • Updated TestFetchAndCacheUnwritableDir to use a regular file path as cacheDir, ensuring a cross-platform failure on directory creation without relying on Unix-specific root permissions.
    • Updated Test_toSchemaURL in pkg/cli/cli_test.go to match the expected file URL prefix generated for absolute paths on Windows and Unix alike.

Verification

  • go test -v ./pkg/schemastore/... passes.
  • go test -v ./pkg/validator/justfile/... passes.
  • go test -v -run Test_toSchemaURL ./pkg/cli/... passes.
  • go vet ./... reports 0 issues.

…andling

- Sanitize host colons in schemastore.cachePathForURL to prevent invalid directory/filename syntax on Windows
- Support rooted POSIX-style paths in justfile resolveImportPath on Windows platforms
- Use platform-independent filepath comparisons and robust tempfile cacheDir in schemastore and justfile tests
- Correct absolute schema URL prefix expectation in cli_test.go

Signed-off-by: Reginald Alfret <reginaldalfret@gmail.com>
@reginaldalfret
reginaldalfret requested a review from a team as a code owner November 2, 2026 17:31
@kehoecj kehoecj added OSS Community Contribution Contributions from the OSS Community waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers labels Nov 2, 2026
@kehoecj

kehoecj commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

@reginaldalfret Thank you for the PR! I'll take a look ASAP.

@kehoecj kehoecj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reginaldalfret Please add a CHANGELOG entry. Thanks!

@kehoecj kehoecj added pr-action-requested PR is awaiting feedback from the submitting developer and removed waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers labels Nov 2, 2026
Signed-off-by: Reginald Alfret <reginaldalfret@gmail.com>
@reginaldalfret

Copy link
Copy Markdown
Author

@kehoecj CHANGELOG entry has been added in commit 88b6a49. Thank you!

This branch has not been deployed

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

Labels

OSS Community Contribution Contributions from the OSS Community pr-action-requested PR is awaiting feedback from the submitting developer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants