Write generated/generator.json only after message generation completes #1595
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 440 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.364
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1595"
general
weight: 0.35
KR-Ravindra
Problem
If message generation does not run to completion,
rclnodejs.init()keeps treating the partialgenerated/tree as complete. Every interface that was never written then fails withMESSAGE_NOT_FOUNDon every start, and the only way out is to deletegenerated/by hand. The two realistic ways to get there are the generating process being killed part-way (SIGKILL/OOM duringnpm install, Ctrl-C ongenerate-ros-messages, CI/container teardown) and any single package failing to generate (EACCES, ENOSPC, a malformed interface). In the second casenpm installalso exits 0, because thepostinstallscript only logs the error, so the partial tree is left behind silently.Root cause
rosidl_gen/index.cjs:87-90copiesgenerator.json(the version markerinit()uses to decide whether regeneration is needed) intogenerated/before the per-prefixgenerateInPath()loop atrosidl_gen/index.cjs:103-105has generated a single interface file.index.js:422-424(getCurrentGeneratorVersion()/forced) only regenerates when that file is absent or carries an older version, so a partial tree with a current-version marker is never regenerated.scripts/generate_messages.cjs:36-38catches the error, printsCaught error: ...and returns normally, so the process exits 0.Fix
rosidl_gen/index.cjs: writegenerated/generator.jsonlast, after thegenerateInPath()loop.generated/is now created withfse.mkdirs()up front (thegenerator.jsoncopy used to create it implicitly). A tree left behind by an interrupted or failed run has no marker,getCurrentGeneratorVersion()returnsnull, andinit()regenerates it on the next start with no other change.scripts/generate_messages.cjs:process.exit(1)in the catch handler sonpm installandnpx generate-ros-messagesreport the failure instead of succeeding with a partial tree.test/test-messsage-generation-overlay.js: regression test that pointsAMENT_PREFIX_PATHat a prefix whose ament index lists a.msgfile that does not exist, runsgenerateAll(true), and asserts that it fails and that nogenerated/generator.jsonwas written.How tested
New test against the unmodified generator:
With the fix:
Also checked that a successful
generateAll(false)followed bygenerateAll(true)still producesgenerated/generator.json,generated/package.jsonandgenerated/srv_msg/, and thatnode scripts/generate_messages.cjsnow exits 1 when a package fails to generate (generated/is left withoutgenerator.json).npx prettier --checkandnpx eslintpass on the changed files.Links
This change was prepared with an AI agent operated by KR-Ravindra, who reviewed and tested it.