Skip to content

[Build] purely-lexical URL operations for resolving symlinks#31

Merged
wlan0 merged 1 commit intomainfrom
lexical-urls-ops
Jun 7, 2025
Merged

[Build] purely-lexical URL operations for resolving symlinks#31
wlan0 merged 1 commit intomainfrom
lexical-urls-ops

Conversation

@wlan0
Copy link
Contributor

@wlan0 wlan0 commented Jun 6, 2025

BuildFSSync.walk relied on an implementation detail to skip traversing the path ".", relative to the build context dir.

Specifically, it assumed that:

  • URL.parentOf() would return false when the parent argument was relative.
  • URL.path(percentEncoded: false) would preserve the relativity of an input path.
    These assumptions held on earlier macOS releases, so the context directory silently remained untouched.

In some versions of macOS , URL.path(percentEncoded: false) always returns an absolute path, regardless of how the URL was created. Because of this change, URL.parentOf() now returns true for ".", and BuildFSSync.walk begins descending into the context directory—something it was never meant to do.

This solution:

  • Remove the hidden dependency on URL.parentOf() for context‑directory detection.
  • Add an explicit check for "." inside BuildFSSync.walk and bail out early.

Replace fragile calls to URL.path(percentEncoded: false) with the stable, documented URL.relativePath, which preserves relativity when the original path was relative.

@wlan0 wlan0 force-pushed the lexical-urls-ops branch from 2a304c0 to 4dfc274 Compare June 7, 2025 03:49
@wlan0 wlan0 force-pushed the lexical-urls-ops branch from 4dfc274 to 9ff6fce Compare June 7, 2025 03:53
#expect(false == fileURL.parentOf(httpURL))
}

@Test func testParentOfRelativePaths() throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test wasn't covering a valid condition in our logic. So, it has been removed

Copy link
Contributor

@adityaramani adityaramani left a comment

Choose a reason for hiding this comment

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

Tested locally on my Mac

@wlan0 wlan0 merged commit 7020082 into main Jun 7, 2025
2 checks passed
@wlan0 wlan0 deleted the lexical-urls-ops branch June 7, 2025 22:32
owenarthur pushed a commit to owenarthur/container that referenced this pull request Jun 10, 2025
`BuildFSSync.walk` relied on an implementation detail to skip traversing
the path ".", relative to the build context dir.

Specifically, it assumed that:
- `URL.parentOf()` would return false when the parent argument was
relative.
- `URL.path(percentEncoded: false)` would preserve the relativity of an
input path.
These assumptions held on earlier macOS releases, so the context
directory silently remained untouched.

In some versions of macOS , `URL.path(percentEncoded: false)` always
returns an absolute path, regardless of how the URL was created. Because
of this change, `URL.parentOf()` now returns true for ".", and
BuildFSSync.walk begins descending into the context directory—something
it was never meant to do.

This solution:
- Remove the hidden dependency on `URL.parentOf()` for context‑directory
detection.
- Add an explicit check for "." inside BuildFSSync.walk and bail out
early.

Replace fragile calls to `URL.path(percentEncoded: false`) with the
stable, documented `URL.relativePath`, which preserves relativity when
the original path was relative.
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.

3 participants