Skip to content

fix: use actual parsed string in literal size error message#82

Merged
BrianLeishman merged 5 commits into
masterfrom
fix/literal-plus-error-message
Mar 11, 2026
Merged

fix: use actual parsed string in literal size error message#82
BrianLeishman merged 5 commits into
masterfrom
fix/literal-plus-error-message

Conversation

@BrianLeishman

Copy link
Copy Markdown
Owner

Summary

  • Error message in findFetchContentEnd was logging s[i+1:j] (includes + from LITERAL+ syntax) but Atoi receives s[i+1:sizeEnd] (numeric part only)
  • Now logs the exact string that was passed to Atoi, making debug output accurate

Spotted by Gemini Code Assist in #81.

Test plan

  • All existing tests pass with race detector

🤖 Generated with Claude Code

The error format string was logging s[i+1:j] (which includes '+' from
LITERAL+ syntax) but Atoi receives s[i+1:sizeEnd] (numeric only).
Log the same string that was actually passed to Atoi.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 11, 2026 13:55
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines an error message within the parsing logic to enhance debugging. Previously, the error message for literal size parsing displayed an incorrect substring, potentially including non-numeric characters. The change ensures that the logged string precisely matches the input provided to the integer conversion function, thereby improving the clarity and utility of error reporting.

Highlights

  • Error Message Accuracy: Corrected an error message in findFetchContentEnd to log the exact string passed to strconv.Atoi, ensuring debug output is accurate and reflects the actual parsed value.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • parse.go
    • Updated the error message format for literal size parsing to display the correct substring that caused the conversion failure.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov-commenter

codecov-commenter commented Mar 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 20.58%. Comparing base (812d3b2) to head (45cd18f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #82      +/-   ##
==========================================
+ Coverage   15.47%   20.58%   +5.11%     
==========================================
  Files          19       19              
  Lines        2074     2074              
==========================================
+ Hits          321      427     +106     
+ Misses       1698     1607      -91     
+ Partials       55       40      -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request correctly addresses an issue where the error message for parsing literal sizes was inaccurate. By changing s[i+1:j] to s[i+1:sizeEnd], the error message now reflects the exact substring that strconv.Atoi attempted to parse, which significantly improves debugging clarity. This is a valuable fix for diagnostic purposes.

Covers parseFetchTokens (quoted strings, escapes, NIL, error paths,
deep nesting, container unwrap), findFetchContentEnd (edge cases,
literals, quoted escapes, unterminated), ParseFetchResponse (empty,
whitespace, quoted), and utility functions (GetTokenName, Token.String,
CheckType, findLineEnd).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR corrects a debug/error message in the IMAP FETCH parser so that, when literal size parsing fails, the error reports the exact substring passed to strconv.Atoi (excluding the optional + from RFC 7888 LITERAL+ syntax).

Changes:

  • Update findFetchContentEnd to log s[i+1:sizeEnd] (the numeric portion) instead of s[i+1:j] in the literal size parse error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

BrianLeishman and others added 3 commits March 11, 2026 10:08
The error-path line in findFetchContentEnd is guarded by a digit-only
loop making Atoi failure unreachable, so the patch check fails on it.
Allow a small threshold so defensive error handling doesn't block PRs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Atoi can fail on digit-only input when the number overflows int.
Test with a 20-digit number to hit the error branch at parse.go:301.
Remove codecov.yml threshold workaround since the line is now covered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@BrianLeishman BrianLeishman merged commit 5862654 into master Mar 11, 2026
3 checks passed
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.

3 participants