Skip to content

intent: items.where with a status NAME on a cross-model item source is silently left unresolved; the refuse: message is an unescaped Java literal #7225

Description

@delchev

Summary

#7164 lets an items: where: condition on the item's function: EntityStatus relation name the status by its seeded NAME, resolved on the raw tree by StatusSymbolResolver.rewriteGeneratesItemsWhere. The parser explicitly allows the item source to be cross-model (fromUses: - IntentParser.java around 7358-7362 sets itemSource = null). For such a source the resolver's statusRelationName(itemEntity) is null and the method returns silently, so { field: Status, value: APPROVED } renders as .eq("Status", "APPROVED") in the generated Java with no diagnostic. The header-level twin two lines above (rewriteGenerates) builds a Target(source, fromUses) and REFUSES a cross-model status name ("a cross-model status must be referenced by its numeric seed id", lines 590-593).

Evidence (origin/master)

components/engine/engine-intent/src/main/java/org/eclipse/dirigible/components/intent/parser/StatusSymbolResolver.java:322-337:

private void rewriteGeneratesItemsWhere(Map<?, ?> generate, String subject) {
    Map<?, ?> items = asMap(generate.get("items"));
    String itemEntity = items == null ? null : text(items, "from");
    String statusRelation = statusRelationName(itemEntity);
    if (statusRelation == null) {
        return;          // <- cross-model item source: silently unresolved
    }

Same PR, same family

GlueIntentGenerator.java:1100 puts the authored refuse: message into the descriptor raw and Generate.java.template:257 interpolates it into a Java string literal ("${itemRefuse} (${fromItemEntity} " + unqualified + ")") unescaped. #7154/#7205 introduced JavaLiterals for exactly this class of defect but only wired it into defaultValue; a refuse: message with a quote or backslash breaks the generated repository's compile the same way. The pre-existing "${guard.message}" / "${check.message}" sites in Repository.java.template (211, 1033, 1048, 1053) share the defect.

Fix

Mirror the header-level rule: refuse a status name on a cross-model item source at parse (id-only there, like every other cross-model nomenclature). And route itemRefuse (and the guard/check messages) through JavaLiterals when they are rendered into a literal.

Found reviewing #7164.

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