Skip to content

Conversation

@shlee-lab
Copy link

@shlee-lab shlee-lab commented Nov 29, 2025

Previously, the implementation assumed that the decrypted message would always split into exactly three parts:

choice-salt-justification

This caused decoding to fail with Malformed decrypted message when the justification itself contained -, since message.split("-") produced more than three segments.

The new logic:

  • Requires parts.length >= 3 instead of parts.length === 3
  • Except for the first and second segments, all remaining segments (re-joined with -) as justification

This preserves the existing format while making the decoder robust to justifications that include the separator which can be used in texts.


PR-Codex overview

This PR modifies the way the message is parsed in the keeperBotShutter.ts file. It changes the condition for validating the number of parts and adjusts how the justification is extracted from the parts array.

Detailed summary

  • Changed the validation condition from checking for exactly 3 parts to checking for fewer than 3 parts.
  • Updated the destructuring of parts to capture all remaining elements into rest.
  • Constructed justification by joining the rest array with the SEPARATOR.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes
    • Improved message parsing to correctly handle messages with multiple separators, allowing proper reconstruction of multi-part content. The decoder now robustly processes complex message structures while preserving existing field integrity.

✏️ Tip: You can customize this high-level summary in your review settings.

Fix decode to allow '-' characters in justification otherwise justification with '-' will spit an error
@shlee-lab shlee-lab requested a review from jaybuidl as a code owner November 29, 2025 18:41
@netlify
Copy link

netlify bot commented Nov 29, 2025

👷 Deploy request for kleros-v2-testnet pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 9d72238

@netlify
Copy link

netlify bot commented Nov 29, 2025

👷 Deploy request for kleros-v2-testnet-devtools pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 9d72238

@netlify
Copy link

netlify bot commented Nov 29, 2025

👷 Deploy request for kleros-v2-neo pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 9d72238

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 29, 2025

Walkthrough

The decode function in the keeper bot shutter script is modified to handle messages with more than three separated parts. The validation changes from requiring exactly three parts to accepting three or more parts, with any additional segments after the second separator joined back into the justification field.

Changes

Cohort / File(s) Summary
Message parsing enhancement
contracts/scripts/keeperBotShutter.ts
Modified decode function to accept messages with more than three separated parts by changing the length validation from strict equality (!= 3) to a less-than check (< 3), and reconstructing the justification field by joining any extra parts back with the original separator.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file, localized change to a parsing function
  • Logic modification is straightforward but reviewer should verify that:
    • Original 3-part message handling remains functional and unchanged
    • Extra parts are correctly concatenated with the separator
    • The use case for handling multi-part justifications is clear and intentional

Poem

🐰 A splitter's work, once rigid and true,
Now bends to accept what comes after part two.
With extra bits joined back with care,
The message flows whole through the autumn air.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating keeperBotShutter.ts to allow hyphens in the justification field during message decoding.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 592243f and 9d72238.

📒 Files selected for processing (1)
  • contracts/scripts/keeperBotShutter.ts (1 hunks)
🔇 Additional comments (1)
contracts/scripts/keeperBotShutter.ts (1)

38-42: The repository clone operation failed, preventing me from verifying the code directly. Based on the information provided in the original review comment, I can assess the review's analysis but cannot confirm all claims.

Rewrite assessment: The original review comment provides sound technical analysis of the logic changes. However, without access to the codebase, I cannot:

  • Confirm if tests already exist for the decode function
  • Verify all usages of decode throughout the codebase
  • Confirm the SEPARATOR constant is properly defined
  • Validate the function's actual behavior with edge cases

Recommendation: The review comment's technical analysis appears correct (logic change from strict equality to less-than validation is sound, backward compatibility holds, suggested test cases are comprehensive). However, verification with actual test execution is needed.


LGTM, but verify test coverage is in place.

The implementation correctly solves the problem:

  • Validates minimum of 3 parts (rejects malformed messages)
  • Preserves backward compatibility for 3-part messages
  • Reconstructs justifications with embedded separators by rejoining the remainder

Before merging, confirm:

  1. Existing tests pass with 3-part messages (backward compatibility)
  2. New tests cover 4+ part messages with embedded separators
  3. Error handling for <3 part messages is tested
  4. Edge case of empty justification ("1-abc-") is handled

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant