Skip to content

foreach can report success after an earlier row fails (public 0.1.10 source) #1

Description

@Lucas-Maake

GenerateDocument() can return true with incomplete output when a non-final foreach row fails. A later successful row overwrites the failure flag.

Verified at commit 9a2f792ac42fd4cc0509dcfc2ff55529b4b57ca8, whose src/info.json identifies TextualTemplates 0.1.10. Both the unmodified standalone Java and Python bundles reproduce this.

Template:

{foreach row in rows}{print value}{end}

Input:

{"rows":[{}, {"value":"B"}]}

Actual: true, document B, and error message Key for printing not found in JSON object: value.

Expected: false, as when the missing-key row is the only row or the last row. Successful generation should not depend on whether a valid row follows the failed row.

Minimal Java reproduction, compiled alongside Java/TextualTemplates.java:

public class Repro {
    public static void main(String[] args) {
        var doc = new TextualTemplates.StringReference();
        var err = new TextualTemplates.StringReference();
        boolean ok = TextualTemplates.GenerateDocument(
            "{foreach row in rows}{print value}{end}".toCharArray(),
            "{\"rows\":[{}, {\"value\":\"B\"}]}".toCharArray(), doc, err);
        System.out.println(ok);
        System.out.println(new String(doc.string));
        System.out.println(new String(err.string));
    }
}

The cause is the loop in GenerateDocumentFromForeach. It continues after GenerateDocumentFromBlock returns false. A local candidate adds && success to the Java loop condition and the equivalent and success in Python.

Validation: upstream test() reports zero failures before and after in both languages. Six cases cover all-valid rows, an empty array, a lone missing-key row, and a missing-key row at the beginning, middle, or end. Before the fix, two cases incorrectly return true in each language; after the fix all six return the expected result. Tested with OpenJDK 21.0.10 and Python 3.10.4. No other language bundle or Timeless Instruction Set execution is claimed.

Prepared and tested by OpenAI Codex for Lucas Maake (@Lucas-Maake); no independent human review is claimed. Your current bounty page targets GenerateDocument 0.1.15, which I have not tested. Could you confirm whether this still affects the eligible version and whether a disclosed AI-assisted, verified report can qualify for a reward paid privately through PayPal? This is not a claim of bounty eligibility or entitlement. No payment details are included here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions