fix(helios-bot): avoid unchecked CLI and mention slices - #211
Conversation
Co-Authored-By: ForgeCode <noreply@forgecode.dev>
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
| let idx = lower.find("@helios")?; | ||
| text.get(idx + "@helios".len()..) |
There was a problem hiding this comment.
Suggestion: mention_suffix accepts any substring containing @helios, so @heliosaurus or foo@helios.example triggers a bot request and webhook dispatch. [logic error]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** crates/helios-bot/src/webhook.rs
**Line:** 65:66
**Comment:**
*Logic Error: `mention_suffix` accepts any substring containing `@helios`, so `@heliosaurus` or `foo@helios.example` triggers a bot request and webhook dispatch.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c626c4eba
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| #[test] | ||
| fn parse_command_rejects_unknown_subcommand_without_indexing() { |
There was a problem hiding this comment.
Put the regression tests on a default-tested target
These new assertions run only when the binary is selected explicitly: crates/helios-bot/Cargo.toml still sets test = false, and the crate has no library target. Cargo's cargo-test(1) documentation says that this setting stops the target from being tested by default, so the workspace test commands in .github/workflows/test.yml, helios-lite-nightly.yml, and platform-tests.yml never execute either new regression test. Re-enable binary tests or move the modules to a library target so CI actually verifies this behavior.
AGENTS.md reference: AGENTS.md:L94-L102
Useful? React with 👍 / 👎.
| }; | ||
| let expected = "unknown subcommand: unknown"; | ||
|
|
||
| assert_eq!(actual, expected); |
There was a problem hiding this comment.
Use the repository's pretty assertion macro
This assertion, and the new assertion in webhook.rs, resolve to the standard-library macro because neither test module imports pretty_assertions::assert_eq. Import the required macro in both modules so the newly added tests follow the repository's assertion convention and retain useful failure diffs.
AGENTS.md reference: AGENTS.md:L13-L26
Useful? React with 👍 / 👎.
| let actual = match parse_command(&fixture) { | ||
| Ok(_) => panic!("unknown subcommand should fail"), | ||
| Err(err) => err.to_string(), |
There was a problem hiding this comment.
Replace the manual test panic with an error unwrap
The new test manually matches the result and calls panic! on unexpected success, contrary to the repository's requirement to use unwrap() or expect() in tests. Extract the error with an unwrap/expect-based result path instead, which also removes this unnecessary branching boilerplate.
AGENTS.md reference: AGENTS.md:L61-L76
Useful? React with 👍 / 👎.
User description
Summary
@heliossuffix with UTF-8-safe string indexingVerification
parse_commandandmention_suffixsymbolscargo test -p helios-bot --bin helios-bot -- --nocapture(16 passed)cargo clippy -p helios-bot --all-targets -- -D clippy::string_slice -D clippy::indexing_slicing -D clippy::disallowed_methodscargo fmt --all -- --checkgit diff --checkTargets the current main Lint Fix failures only; does not alter decoder suppression or Windows test code.
CodeAnt-AI Description
Prevent crashes and incorrect mention extraction in the Helios bot
What Changed
@heliosImpact
✅ Fewer bot crashes from invalid CLI input✅ Reliable Unicode mention handling✅ Clearer errors for unknown commands💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.