luigidemasi commented on code in PR #150:
URL: https://github.com/apache/camel-kit/pull/150#discussion_r4478080025
##########
kit/camel-kit-core/src/main/java/org/apache/camel/kit/ship/controller/ShipStageResult.java:
##########
@@ -280,6 +284,34 @@ private static void requireReport(String report) throws
IOException {
utf8(report, MAX_REPORT_BYTES, "stage report");
}
+ private static String extractJsonObject(String text) throws IOException {
+ if (text == null) {
+ return text;
+ }
+ String stripped = text.strip();
+ if (stripped.startsWith("{")) {
+ return stripped;
+ }
+ Matcher m = JSON_FENCE.matcher(text);
+ if (m.find()) {
+ String first = m.group(1).strip();
+ if (m.find()) {
+ throw new IOException("Pi stage result contains conflicting
fenced JSON envelopes");
+ }
+ return first;
Review Comment:
[P2] Reject JSON envelopes outside the selected fence
The [earlier ambiguity
finding](https://github.com/apache/camel-kit/pull/150#discussion_r4452160698)
remains when only one of the conflicting envelopes is fenced. `m.find()`
searches for a second matching fence, then `return first` discards the rest of
the response. A fenced DESIGN result with `materialAmbiguity: false` followed
by a bare corrected JSON result with `materialAmbiguity: true` and an
unanswered question is still accepted. With the existing Pi RPC fixture and
real coordinator, DESIGN completes with no questions and PLAN starts under
SMART; the corrected result alone pauses, and the parser before the extraction
change rejects the mixed response before PLAN starts.
Please reject additional JSON values outside the selected block, regardless
of fencing, and add a mixed fenced/raw regression test. The array check also
needs to validate the root shape: `[null, <valid envelope>]` is still accepted
because the prefix ends in a comma rather than `[`. Keeping the allowed wrapper
grammar narrow would preserve the single-object boundary without adding more
formatting-specific checks.
_AI-generated by Codex on behalf of @luigidemasi._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]