CLI exits with code 0 when the generated meta-model or instance model is invalid

Open Beginner friendly
#415 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
cli

Research direction

Start by grepping the CLI module for the literal [WARNING] Generated instance model failed validation string to find the validation handler, then look at the main entry point that converts the run into an exit code. The same place almost certainly handles the meta-model validation path (.ecore save plus the -t transform), so both branches need to report errors and return 1 instead of 0. Done means both reproduction commands in the issue exit with code 1 and the existing CLI tests still pass.

Written by the indexing model from the issue text.

Description

area: cli
What happened

The CLI reports errors in the generated view type or view as plain output lines and still exits with code 0, so scripts and CI jobs cannot detect them:

  • If the generated meta-model is invalid, the CLI prints the error, saves the .ecore file anyway, transforms the instance models against it (with -t) and exits with 0.
  • If the generated instance model is invalid, the CLI prints [WARNING] Generated instance model failed validation: followed by the errors, saves the .xmi file and exits with 0.

Expected: both cases are errors. The CLI prints them as errors and exits with code 1.

How to reproduce

Invalid instance model: restaurant.ecore from test-resources (Restaurant.name is required), an instance model without a name, and this query:

export v to "http://example.org/v"

import "http://example.org/restaurant"

from Restaurant r create R {
    r.name
}
<restaurant:Store xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:restaurant="http://example.org/restaurant">
  <restaurants address="Main Street 1"/>
</restaurant:Store>

java -jar <cli>.jar -m <meta-model dir> -i <instance dir> -t out.xmi q.nj

Invalid meta-model: same meta-model, a query that names a class like the data type Money and copies an attribute of that data type:

from Food f create Money {
    f.name
}

from Restaurant r create R {
    r.dailyRevenue
}

java -jar <cli>.jar -m <meta-model dir> -g out.ecore q.nj

(After #213 this query is a validation error; the exit code is still wrong for any other error that the meta-model generator reports.)

Version

main at c4ff36c

Environment

Java 21 (Temurin), macOS

Logs
[WARNING] Generated instance model failed validation:
[ERROR] The required feature 'name' of 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl/http://example.org/v#R@4dad0eed{out.xmi#//@rs.0}' must be set
(exit code 0)

[ERROR] There may not be two classifiers named 'Money'
(exit code 0)
Dominant language
Java
Stars
3
Forks
6
Avg merge
19h 10m
Merged PRs (30d)
34

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vitruv-tools/NeoJoin

All issues in vitruv-tools/NeoJoin

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.