feat(io): opt-out of format-aware parsing for Read/Write (#197)#620
Closed
feat(io): opt-out of format-aware parsing for Read/Write (#197)#620
Conversation
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
Closes #197. ARO-0040's format-aware Read/Write silently misparses files whose extension matches a known format but whose content does not — e.g. a
.txtfile of plain integers gets run through the key=value parser and binds to[:], thenSplitfails on_expression_ = [:]. The only workaround was renaming the file to a non-recognised extension.What changed
Implements Option B from the issue (explicit format qualifier — strict superset of the
:raw-only minimum). Resolution order onRead/Writeis now:raw(or legacyas String) qualifier → bypass formatting entirelyjson,csv,yaml, …) → override extension detectionFileFormat.detect(from:)The
rawform is also recognised on the URL branches of Read/Write, mirroring the existingas Stringhandling. The legacyas Stringform continues to work.Files
Sources/ARORuntime/FileSystem/FileFormat.swift— newfromQualifier(_:)andisRawQualifier(_:)helpersSources/ARORuntime/Actions/BuiltIn/ExtractAction.swift— Read action (file + URL branches)Sources/ARORuntime/Actions/BuiltIn/ResponseActions.swift— Write actionExamples/FormatAwareIO/main.aro— demonstrates:rawround-trip and forced:jsonExamples/FormatAwareIO/test.hint— asserts the new raw.txtround-tripProposals/ARO-0040-format-aware-io.md— documents therawqualifier and the updated specifier tableAcceptance criteria
Read the <x: raw> from "./file.txt".returns the file content as a plainStringWrite the <x: raw> to "./file.txt".writes the string value of<x>without serialisationrawqualifier and the format-override tableExamples/FormatAwareIO/demonstrates:rawTest plan
swift build— cleanRead the <raw-content: raw>from a.txtfile of integers correctly returns the raw string; without:rawthe legacy behaviour (empty map) is unchangedswift test --filter "Read|Write|Format"— 103 passing, including the existingas Stringtestsswift test— 1575/1576 passing; the single failure is the flaky network integration testWrite to URL performs POST request("Connection failed: The network connection was lost"), unrelated to this changearo run Examples/FormatAwareIO— full example runs end-to-end and demonstrates both:rawround-trip and forced:json