Repository navigation
feat(cli): reject unknown keys in cartesi.toml + build for production - #571
Merged
brunomenezes merged 4 commits intoOct 28, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: f3aade6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Coverage Report
📁 File Coverage (20 files)
|
tuler
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cartesi.tomlsilently ignored any key the CLI doesn't read: a misspelling, a key of another builder, a key written after the wrong table header, or a key of a removed feature such as[withdrawal.config]. The parser now rejects them, naming the key, the table and the keys that table accepts, as suggested in the review of #551. It also rejects a drive or nvram that isn't a table, such as[[drives.root]], which used to become the default root drive. Missing keys keep their defaults, and drive names, nvram labels and[machine.env]variables stay free.Also, the CLI is now built for production by default, so errors print only their message, as below, instead of a minified class name and a stack trace. I tested the npm bundle version + mac-os binary
Closes #555.
Here is a toml file with a few test cases.
cartesi.toml with commented wrong setups
Changes:
config.ts:UnknownConfigKeyErrorand anassertKnownKeyshelper, with the accepted keys listed next to each parser: the top level,[machine],[nvrams.*],[withdrawal], and[drives.*]per builder, so a key of another builder is rejected too. The drive message names the builder in effect, markedby defaultwhen omitted. Every unknown key of a table is reported at once.InvalidTableErrorfor[drives],[nvrams], each drive and nvram,[machine]and[withdrawal]given as a non-table, e.g.Invalid [drives.root]: expected a table, got [{"builder":"empty","size":"1Mi"}].[withdrawal.config]from before feat(cli): derive the accounts drive layout from the built machine #551 fails as unknown keyconfigin[withdrawal], with no migration code.base.ts:getProjectSdkno longer swallows parse errors, sohash,address-book,send,deposit,foreclose,refundandwithdrawreport an invalidcartesi.tomlinstead of hashing the snapshot with the default SDK image.nvrams.output.sdkin the nvram test) and was ignored, so that test built with the default SDK.full.tomlis now a valid, commented reference that sets every accepted key to a non-default value at least once;no_boot.tomlusedassert_rolling_update, which never existed (the key isassert_rolling_template); the emptybootargs.tomlis removed.full.tomlparses to the expected config with a strict comparison, so a key the parser stops reading or a new unset field fails the test; unknown keys in each table, keys of another builder, several keys at once, non-tables,-cmerging and the free names;getMachineHashon an invalid config.-cfiles are checked after merging, and merging can't unset keys, so a later file that changes a drive's builder now fails on the earlier file's builder-specific keys. Overrides within the same builder keep working.build.ts: the CLI is built for production unlessNODE_ENVsays otherwise. The release build didn't set it, so the npm package printed the minified error class and its stack trace instead of the message shown above.index.ts: the error handler also handles rejected promises. Bun, which runs the compiled binaries, doesn't turn them into uncaught exceptions, so the binaries skipped the handler and printed Bun's own error report.