Conversation
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
🤖 Augment PR SummarySummary: This PR adds explicit multi-document input handling to CLI input parsing. Changes:
Technical Notes: Regular linting and validation can process each document independently, while rewrite-oriented commands reject ambiguous multi-document sources. 🤖 Was this summary useful? React with 👍 or 👎 |
| inline auto at_end_of_stream(std::istream &stream) -> bool { | ||
| auto character{stream.peek()}; | ||
| while (character != std::char_traits<char>::eof() && | ||
| std::isspace(static_cast<unsigned char>(character)) != 0) { |
There was a problem hiding this comment.
src/input.h:175: std::isspace accepts characters such as form-feed and vertical-tab that JSON does not define as whitespace. Consequently, stdin containing a valid JSON value followed only by \f is accepted as a single JSON document here, whereas the JSON/JSONL parsers correctly reject that trailing byte.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| return result; | ||
| } | ||
|
|
||
| // Standard input that carries more than one JSON document is JSONL |
There was a problem hiding this comment.
src/input.h:307: A valid YAML stream whose first document is also valid JSON but has no initial --- is routed here instead of to the YAML parser; for example, {"foo": "first"}\n---\nfoo: second is valid multi-document YAML but JSONL rejects the --- line. This makes the new stdin multi-document YAML support depend on an optional first-document marker.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
1 issue found across 16 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/input.h">
<violation number="1" location="src/input.h:280">
P1: This fallback classifies newline-delimited JSON on stdin as YAML before JSONL gets a chance to parse it. Move the JSONL attempt before the YAML fallback so `lint --fix` rejects JSONL as multiple documents and downstream commands retain the correct input type.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| .positions = std::move(positions), | ||
| .property_storage = std::move(property_storage), | ||
| .yaml = true}; | ||
| documents = read_yaml_documents(yaml_stream); |
There was a problem hiding this comment.
P1: This fallback classifies newline-delimited JSON on stdin as YAML before JSONL gets a chance to parse it. Move the JSONL attempt before the YAML fallback so lint --fix rejects JSONL as multiple documents and downstream commands retain the correct input type.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/input.h, line 280:
<comment>This fallback classifies newline-delimited JSON on stdin as YAML before JSONL gets a chance to parse it. Move the JSONL attempt before the YAML fallback so `lint --fix` rejects JSONL as multiple documents and downstream commands retain the correct input type.</comment>
<file context>
@@ -204,38 +258,199 @@ inline auto read_file(const std::filesystem::path &path) -> ParsedJSON {
- .positions = std::move(positions),
- .property_storage = std::move(property_storage),
- .yaml = true};
+ documents = read_yaml_documents(yaml_stream);
} catch (...) {
throw sourcemeta::core::JSONFileParseError(stdin_path(), json_error);
</file context>
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Signed-off-by: Juan Cruz Viotti jv@jviotti.com