Repository navigation
fix(cli): warn when review add --type is not a configured type - #682
Merged
agavra merged 1 commit intoSep 7, 2026
Merged
Conversation
`CommentType::from_id` maps any non-empty id to `Custom`, which is right for the TUI, where ids come from validated `comment_types` config. The CLI had nothing to check against, so `--type isue` was stored, exported as `**[ISUE]**`, and badged as an unknown type, all at exit 0. Agents seeding comments are the ones who notice least. Warns rather than rejects, for two reasons. `comment_types` is unset by default, and under that default every id but `none` is undefined — rejecting would break `--type issue`, which the agent skill documents. And a scripted caller should not start failing because someone edited a config it does not control. So an absent list means no opinion, and a present one that omits the id gets a warning naming the valid ids. The warning goes to stderr, leaving stdout parseable JSON. `add` already read config for the `username` fallback, so the check reuses that read instead of adding a second one; `resolve_cli_author` now takes the config rather than loading it. Fixes agavra#681 Test plan: - cargo test: 1585 passed, 0 failed. cargo fmt --check, clippy clean (one pre-existing bkt.rs warning) - Five new unit tests: warns and names valid ids for an unconfigured id, silent for a configured one, silent when comment_types is absent or the config is default, silent for `none`, and the comment is still written when the type is unconfigured - Manually, with comment_types = [note, issue]: `--type issue` prints nothing on stderr; `--type isue` prints the warning to stderr, keeps stdout as valid JSON (checked with json.load), and exits 0. With no config file, both `--type issue` and the `none` default stay silent
agavra
approved these changes
Sep 7, 2026
agavra
left a comment
Owner
There was a problem hiding this comment.
Thank you @martintrojer for the contribution! This looks good to me.
1 task
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.
Fixes #681.
CommentType::from_idmaps any non-empty id toCustom. That is right for the TUI, where ids come from validatedcomment_typesconfig, but the CLI had nothing to check against — so--type isuewas stored, exported as**[ISUE]**, and badged as an unknown type, all at exit 0.Why warn instead of reject
Two reasons, and I would rather flag them than have them found in review.
comment_typesis unset by default, and under that default every id butnoneis undefined. Rejecting unknown ids would make--type issuean error on a stock install — which is exactly what the agent skill tells agents to pass. Second, a scripted caller should not start failing because someone edited a config it does not control.So: an absent or empty
comment_typesmeans no opinion and no warning. A configured list that omits the id gets a warning naming the valid ids. The comment is written either way and the exit code stays 0.If you would rather have a hard error, or a
--strict-typeflag, say so and I will rework it — the placement is the same either way.The warning goes to stderr, so stdout stays parseable JSON.
addalready read config for theusernamefallback, so the check reuses that read rather than adding a second one;resolve_cli_authornow takes the config instead of loading it.Test plan
cargo test: 1585 passed, 0 failed.cargo fmt --checkandclippy --all-targetsclean (one pre-existingbitbucket/bkt.rswarning, present on main)comment_typesis absent or the config is default, silent fornone, and the comment is still written when the type is unconfiguredcomment_types = [note, issue]:--type issue→ nothing on stderr--type isue→Warning: comment type 'isue' is not configured; known types: note, issueon stderr, stdout still valid JSON (verified withjson.load), exit 0--type issueand thenonedefault stay silent