Skip to content

CLAUDE.md: error handling + test instructions updates#412

Open
malcolmgreaves wants to merge 1 commit intomainfrom
mg/claude_settings_tweaks
Open

CLAUDE.md: error handling + test instructions updates#412
malcolmgreaves wants to merge 1 commit intomainfrom
mg/claude_settings_tweaks

Conversation

@malcolmgreaves
Copy link
Copy Markdown
Collaborator

Updated the CLAUDE.md file to expound on error handling conventions.
OxenError is top-level unifying type. Encourage to use specific errors and
wrap in OxenError variants with #[from] conversions.

Included instruction to ensure the oxen-server server is running for tests.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Testing guidance added: many tests require a local server on port 3000; instructions included for starting it when connections fail.
    • Error-handling guidance clarified: prefer Result-based returns, prohibit unwrap/expect except in tests, favor specific/local error types while ensuring a unified top-level error wrapper for outward-facing APIs.

Walkthrough

Documentation-only change to .claude/CLAUDE.md adding a testing note that many tests require oxen-server on port 3000 (startup command provided) and replacing a strict “use OxenError for all errors” rule with broader error-handling guidance (use Result<T, Error>, avoid .unwrap()/.expect() outside tests, prefer specific error types, keep OxenError as top-level wrapper).

Changes

Cohort / File(s) Summary
Documentation
.claude/CLAUDE.md
Added note that tests expect oxen-server on port 3000 with cargo run -p oxen-server start. Reworked Error Handling guidance: prefer Result<T, Error> for fallible ops; disallow .unwrap()/.expect() on Result/Option except test-only; prefer specific/local error enums; require OxenError variants to wrap other errors (e.g., Box<>, derive #[from]) and keep OxenError as the top-level unifying error where needed; continue to encourage ?-based propagation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested reviewers

  • gschoeni
  • jcelliott
  • subygan

Poem

🐰 I hopped through docs with careful care,
Tests now seek the server on port three-thousand there.
Errors tucked in boxes, no unwraps to fight,
Result and ? guide the code by moonlight.
A rabbit dances — docs polished and bright! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: updates to CLAUDE.md documentation covering error handling conventions and test server instructions.
Description check ✅ Passed The description clearly relates to the changeset, detailing the error-handling convention updates and test server requirements added to CLAUDE.md.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mg/claude_settings_tweaks

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/CLAUDE.md:
- Line 105: The sentence at Line 105 is malformed and ambiguous: replace the
broken fragment ".on a `Result`" with the intended method reference (for example
".expect() on `Result`") so the rule reads clearly (e.g., "Avoid using
`.unwrap()` or `.expect()` on a `Result`. It is only OK to do this within a test
case."). Update the rule text to explicitly mention the correct method names
(`.unwrap()`, `.expect()`) and reference `Result` as the type to remove the
broken code span and ambiguity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 92fea7f0-d23e-47dc-b9ee-1b43f85d40c4

📥 Commits

Reviewing files that changed from the base of the PR and between ba33cc2 and ba7a074.

📒 Files selected for processing (1)
  • .claude/CLAUDE.md

@malcolmgreaves malcolmgreaves force-pushed the mg/claude_settings_tweaks branch 2 times, most recently from 8f2824a to 9aaff6f Compare April 3, 2026 20:22
Updated the `CLAUDE.md` file to expound on error handling conventions.
`OxenError`  is top-level unifying type. Encourage to use specific errors and
wrap in `OxenError` variants with `#[from]` conversions.

Included instruction to ensure the `oxen-server` server is running for tests.
@malcolmgreaves malcolmgreaves force-pushed the mg/claude_settings_tweaks branch from 9aaff6f to 5c3102e Compare April 3, 2026 21:57
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/CLAUDE.md:
- Line 106: Fix the typo in the test-only code note: change the misspelled word
"descrptive" to "descriptive" inside the phrase `.expect(<descrptive explanation
of invariant that was violated>)` so it reads `.expect(<descriptive explanation
of invariant that was violated>)` in the test exception note.
- Line 107: In the sentence that reads "Use as specific of an error type as
possible for a function. Don't use a wider type unless it's necessary. When
making modules and related pieces of code, try to use a locally-defined error
enum for them if they all have similiar errors." fix the typo by replacing the
word "similiar" with the correct spelling "similar" so the final sentence reads
"...if they all have similar errors." and keep the surrounding guidance
unchanged.
- Line 108: Fix the typos in the guidance sentence so it reads correctly: change
"a `OxenError` variant" to "an `OxenError` variant" and correct "similiar" to
"similar" in the same line that references wrapping other modules' error types
and using `Box<>` with `#[from]`; keep the rest of the guidance unchanged and
ensure backticks around `OxenError`, `Box<>`, and `#[from]` remain intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b1f96ff-6348-4a6c-9a2f-7e458183c3d3

📥 Commits

Reviewing files that changed from the base of the PR and between 9aaff6f and 5c3102e.

📒 Files selected for processing (1)
  • .claude/CLAUDE.md

- Implement proper error propagation through the `?` operator
- Use the result type (`Result<T, Error>`) when an operation could fail.
- Never use `.unwrap()` or `.expect()` on a `Result` or on an `Option`.
+ Exception: In test-only code, it is ok to use use `.expect(<descrptive explanation of invariant that was violated>)` since we want to fail fast and have good stack traces for failing test cases.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in test exception note.

The word "descrptive" is misspelled.

✏️ Proposed fix
-  + Exception: In test-only code, it is ok to use use `.expect(<descrptive explanation of invariant that was violated>)` since we want to fail fast and have good stack traces for failing test cases.
+  + Exception: In test-only code, it is ok to use `.expect(<descriptive explanation of invariant that was violated>)` since we want to fail fast and have good stack traces for failing test cases.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/CLAUDE.md at line 106, Fix the typo in the test-only code note:
change the misspelled word "descrptive" to "descriptive" inside the phrase
`.expect(<descrptive explanation of invariant that was violated>)` so it reads
`.expect(<descriptive explanation of invariant that was violated>)` in the test
exception note.

- Use the result type (`Result<T, Error>`) when an operation could fail.
- Never use `.unwrap()` or `.expect()` on a `Result` or on an `Option`.
+ Exception: In test-only code, it is ok to use use `.expect(<descrptive explanation of invariant that was violated>)` since we want to fail fast and have good stack traces for failing test cases.
- Use as specific of an error type as possible for a function. Don't use a wider type unless it's necessary. When making modules and related pieces of code, try to use a locally-defined error enum for them if they all have similiar errors.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in error type guidance.

"similiar" is misspelled.

✏️ Proposed fix
-- Use as specific of an error type as possible for a function. Don't use a wider type unless it's necessary. When making modules and related pieces of code, try to use a locally-defined error enum for them if they all have similiar errors.
+- Use as specific of an error type as possible for a function. Don't use a wider type unless it's necessary. When making modules and related pieces of code, try to use a locally-defined error enum for them if they all have similar errors.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/CLAUDE.md at line 107, In the sentence that reads "Use as specific
of an error type as possible for a function. Don't use a wider type unless it's
necessary. When making modules and related pieces of code, try to use a
locally-defined error enum for them if they all have similiar errors." fix the
typo by replacing the word "similiar" with the correct spelling "similar" so the
final sentence reads "...if they all have similar errors." and keep the
surrounding guidance unchanged.

- Never use `.unwrap()` or `.expect()` on a `Result` or on an `Option`.
+ Exception: In test-only code, it is ok to use use `.expect(<descrptive explanation of invariant that was violated>)` since we want to fail fast and have good stack traces for failing test cases.
- Use as specific of an error type as possible for a function. Don't use a wider type unless it's necessary. When making modules and related pieces of code, try to use a locally-defined error enum for them if they all have similiar errors.
- Make sure there's a `OxenError` variant for every error type. Be liberal in wrapping other modules error types, or other specific error types, in a new variant. Use a `Box<>` wrapper for it and have a `#[from]` to derive.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typos in OxenError variant guidance.

Two issues on this line:

  • Article should be "an" before OxenError (vowel sound)
  • "similiar" is misspelled
✏️ Proposed fixes
-- Make sure there's a `OxenError` variant for every error type. Be liberal in wrapping other modules error types, or other specific error types, in a new variant. Use a `Box<>` wrapper for it and have a `#[from]` to derive.
+- Make sure there's an `OxenError` variant for every error type. Be liberal in wrapping other modules error types, or other specific error types, in a new variant. Use a `Box<>` wrapper for it and have a `#[from]` to derive.
-- Make sure there's a `OxenError` variant for every error type. Be liberal in wrapping other modules error types, or other specific error types, in a new variant. Use a `Box<>` wrapper for it and have a `#[from]` to derive.
+- Make sure there's an `OxenError` variant for every error type. Be liberal in wrapping other modules error types, or other specific error types, in a new variant. Use a `Box<>` wrapper for it and have a `#[from]` to derive.

Actually, there's also "similiar" that needs fixing:

-- Use as specific of an error type as possible for a function. Don't use a wider type unless it's necessary. When making modules and related pieces of code, try to use a locally-defined error enum for them if they all have similiar errors.
+- Use as specific of an error type as possible for a function. Don't use a wider type unless it's necessary. When making modules and related pieces of code, try to use a locally-defined error enum for them if they all have similar errors.

Combined fix:

-- Make sure there's a `OxenError` variant for every error type. Be liberal in wrapping other modules error types, or other specific error types, in a new variant. Use a `Box<>` wrapper for it and have a `#[from]` to derive.
+- Make sure there's an `OxenError` variant for every error type. Be liberal in wrapping other modules error types, or other specific error types, in a new variant. Use a `Box<>` wrapper for it and have a `#[from]` to derive.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/CLAUDE.md at line 108, Fix the typos in the guidance sentence so it
reads correctly: change "a `OxenError` variant" to "an `OxenError` variant" and
correct "similiar" to "similar" in the same line that references wrapping other
modules' error types and using `Box<>` with `#[from]`; keep the rest of the
guidance unchanged and ensure backticks around `OxenError`, `Box<>`, and
`#[from]` remain intact.

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