Use SystemPath for SandboxRuntimeConfiguration#22
Open
chrisgeo wants to merge 2 commits into
Open
Conversation
d9b7ed9 to
863733b
Compare
Converts RuntimeConfiguration.path, runtimeConfigurationPath, and the readRuntimeConfiguration(from:) parameter from URL to FilePath. Following the migration pattern from apple#1480 (HostDNSResolver), apple#1518 (PacketFilter), and discussion apple#1481. The two server-side callers (ContainersService, SandboxService) get minimal URL <-> FilePath bridge calls. Bundle.create still requires URL (Foundation API) so the bridge stays at that boundary. Bundle+Log.swift in the same module is intentionally NOT converted in this PR: all three of its callers use Foundation FileHandle APIs that require URL, and converting bundle.containerLog without simultaneously updating those callers (in ContainersService and SandboxService) would expand the PR scope significantly. Bundle+Log can be converted later as part of a SandboxService/ContainersService cluster conversion.
…sOf:). Address review feedback on the URL → FilePath conversion of RuntimeConfiguration.path: 1. FilePath's default Codable encoding exposes its internal _storage as a keyed container, while URL's default encoding produced a plain absoluteString. Without this fix, runtime-configuration.json files written by daemons before the migration would fail to decode after upgrade. Add explicit CodingKeys + encode(to:) / init(from:) that serialize path as a plain string and accept either form (file:// or bare path) on decode for backward compatibility. Add a regression test for the legacy URL format. 2. Restore Data(contentsOf: URL(fileURLWithPath:)) for reading the config file, matching the codebase precedent (Bundle.swift, ConfigurationLoader.swift, EntityStore.swift). FileManager.contents would have lost typed CocoaError diagnostics on I/O failure.
3eed0a2 to
cc4be53
Compare
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
Converts
SandboxRuntimeConfigurationfromURLtoSystemPackage.FilePathfor filesystem path handling, mirroring the established migration pattern (apple#1480, apple#1518, just-merged forks #20-21).Two-commit PR — second commit addresses review feedback on Codable/wire-format.
Changes
Commit 1 — Use SystemPath for SandboxRuntimeConfiguration
RuntimeConfiguration.path: URL→FilePath(public API)runtimeConfigurationPath: URL→FilePath(computed)readRuntimeConfiguration(from: URL)→from: FilePathContainersService.swiftandSandboxService.swift:FilePath(url.path(percentEncoded: false))at producer,URL(fileURLWithPath: fp.string)atBundle.createconsumer (still requires URL — Foundation API)Commit 2 — Codable backward compatibility + restore Data(contentsOf:)
FilePath's default Codable encoding exposes its internal_storageas a keyed container, whileURL's default encoding produced a plainabsoluteString. Without explicitCodingKeys+encode/init(from:), runtime-configuration.json files written by daemons before this migration would fail to decode after upgrade.pathas a plain string and accepts either form (file:// URL or bare path) on decode for backward compatibility.testRuntimeConfigurationDecodesLegacyURLPathFormat.Data(contentsOf: URL(fileURLWithPath:))(wasFileManager.default.contents(atPath:)) to match codebase precedent (Bundle.swift,ConfigurationLoader.swift,EntityStore.swift).Out of scope
Bundle+Log.swift(sibling file in the same module): all 3 callers useFileHandle(forReadingFrom:),FileHandle(forWritingTo:),Darwin.open(... .path, ...)— Foundation APIs requiring URL. Converting just this file would create cross-file compile breaks. Should be bundled with the broaderSandboxService/ContainersServicemigration (CHAOS-1467).Context
Test plan
swift test --filter RuntimeConfigurationTests— 3 tests pass (including new legacy-format test)swift test --filter ContainerAPIServiceTests— full module passes