Skip to content

Conversation

@ReneWerner87
Copy link
Member

@ReneWerner87 ReneWerner87 commented Jul 13, 2025

error instead of boolean return

Benchmark_ParseUint/fiber-12                  172685805	       6.949 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint/fiber-12                  172395474	       6.984 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint/fiber_bytes-12            167209564	       7.162 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint/fiber_bytes-12            161316883	       7.248 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint/default-12                 89826800	       13.52 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint/default-12                 89406565	       13.68 ns/op       0 B/op       0 allocs/op

Benchmark_ParseInt/fiber-12                   158532987        7.442 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt/fiber-12                   154777971	       7.710 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt/fiber_bytes-12             157400030	       7.453 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt/fiber_bytes-12             148624418	       7.400 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt/default-12                  78927678	       15.97 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt/default-12                  78261080	       16.26 ns/op       0 B/op       0 allocs/op

Benchmark_ParseInt32/fiber-12                 164397682	       7.234 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt32/fiber-12                 164329150	       7.319 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt32/fiber_bytes-12           159049194	       7.556 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt32/fiber_bytes-12           155705494	       7.697 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt32/default-12                71818300	       16.92 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt32/default-12                78039262	       15.83 ns/op       0 B/op       0 allocs/op

Benchmark_ParseInt16/fiber-12                 232986352	       5.165 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt16/fiber-12                 232214074	       5.256 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt16/fiber_bytes-12           220412829	       5.398 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt16/fiber_bytes-12           222333234	       5.409 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt16/default-12               100000000	       11.07 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt16/default-12               100000000	       11.08 ns/op       0 B/op       0 allocs/op

Benchmark_ParseInt8/fiber-12                  260329051	       4.543 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt8/fiber-12                  265292354	       4.541 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt8/fiber_bytes-12            260297640	       4.635 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt8/fiber_bytes-12            260662333	       4.669 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt8/default-12                134202080	       8.700 ns/op       0 B/op       0 allocs/op
Benchmark_ParseInt8/default-12                137497462	       8.702 ns/op       0 B/op       0 allocs/op

Benchmark_ParseUint32/fiber-12                166919528	       6.991 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint32/fiber-12                172230549	       7.004 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint32/fiber_bytes-12          168104906	       7.182 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint32/fiber_bytes-12          166743417	       7.189 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint32/default-12               88639659	       13.70 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint32/default-12               78153198	       13.74 ns/op       0 B/op       0 allocs/op

Benchmark_ParseUint16/fiber-12                265107002	       4.425 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint16/fiber-12                265636831	       4.517 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint16/fiber_bytes-12          255349777	       4.674 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint16/fiber_bytes-12          250084923	       4.722 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint16/default-12              133589893	       9.006 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint16/default-12              136365088	       8.863 ns/op       0 B/op       0 allocs/op

Benchmark_ParseUint8/fiber-12                 326680580	       3.719 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint8/fiber-12                 313552454	       3.739 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint8/fiber_bytes-12           325318082	       3.697 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint8/fiber_bytes-12           321770954	       3.699 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint8/default-12               182636923	       6.678 ns/op       0 B/op       0 allocs/op
Benchmark_ParseUint8/default-12               184060842	       6.756 ns/op       0 B/op       0 allocs/op

Benchmark_ParseFloat64/fiber-12               100000000	       11.11 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat64/fiber-12               100000000	       11.09 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat64/fiber_bytes-12         127174759	       9.525 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat64/fiber_bytes-12         124214686	       9.577 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat64/default-12              50066755	       24.16 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat64/default-12              49396011	       24.80 ns/op       0 B/op       0 allocs/op

Benchmark_ParseFloat32/fiber-12               100000000	       11.71 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat32/fiber-12               100000000	       11.85 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat32/fiber_bytes-12         100000000	       11.17 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat32/fiber_bytes-12         100000000	       10.43 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat32/default-12              46055755	       25.65 ns/op       0 B/op       0 allocs/op
Benchmark_ParseFloat32/default-12              45263090	       25.78 ns/op       0 B/op       0 allocs/op

Summary by CodeRabbit

  • Refactor

    • Updated parsing functions to provide detailed error reporting for parsing failures instead of simple success flags.
  • Tests

    • Adjusted tests and benchmarks to validate error responses, aligning with the enhanced parsing error handling.
  • Documentation

    • Updated benchmark results in the README to reflect revised performance metrics for parsing functions.

error instead of boolean return
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner July 13, 2025 19:31
@ReneWerner87 ReneWerner87 requested review from efectn, gaby and sixcolors and removed request for a team July 13, 2025 19:31
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 13, 2025

## Walkthrough

The parsing functions for integers and floating-point numbers were updated to return detailed error values instead of boolean success flags. All related helper functions and their corresponding tests and benchmarks were modified to use and check for errors, aligning the API with Go's standard error-handling conventions.

## Changes

| Files          | Change Summary                                                                                   |
|----------------|------------------------------------------------------------------------------------------------|
| parse.go       | Updated all parsing functions to return `error` values instead of boolean flags; adjusted internal logic and added `strconv` import for error types. |
| parse_test.go  | Modified all tests and benchmarks to check for errors instead of boolean success flags.         |
| README.md      | Updated benchmark results reflecting new parsing function implementations and performance metrics.|

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Caller
    participant Parser
    participant strconv

    Caller->>Parser: ParseInt(s)
    Parser->>Parser: Validate input
    alt Invalid syntax or overflow
        Parser->>strconv: Create NumError
        Parser->>Caller: return (0, error)
    else Valid input
        Parser->>Caller: return (value, nil)
    end

Possibly related PRs

  • add parse functions #133: The main PR modifies the existing parsing functions to return detailed error values instead of boolean success flags, updating function signatures and internal logic accordingly, while the retrieved PR initially introduced these parsing functions with boolean success returns and added benchmarks; thus, the main PR is a direct continuation and modification of the same parsing functions introduced in the retrieved PR.

Suggested labels

✏️ Feature

Suggested reviewers

  • gaby
  • sixcolors
  • efectn

Poem

A nibble, a byte, a number to parse,
Now errors are detailed, precise and sparse.
No more guessing with booleans, hooray!
Just clear Go errors to brighten your day.
With every test passing, the code hops ahead—
🐇 Parsing made better, just as the rabbit said!


<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 862e7a044e6b23e5c5d1b283cbf07509de98ec15 and 0df52a08919755769d8cfaa8bc3c163d91e21237.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `parse.go` (10 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (2)</summary>

<details>
<summary>📓 Common learnings</summary>

Learnt from: ReneWerner87
PR: gofiber/fiber#2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The ParamsInt function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.


Learnt from: ReneWerner87
PR: gofiber/fiber#2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The ParamsInt function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.


Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse.go:106-107
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The IsZero function for time.Time structs in the ClickHouse storage driver was returning false even for zero value time.Time structs. As a result, a different verification logic was implemented to avoid bugs.


Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse.go:106-107
Timestamp: 2024-07-01T15:49:51.308Z
Learning: The IsZero function for time.Time structs in the ClickHouse storage driver was returning false even for zero value time.Time structs. As a result, a different verification logic was implemented to avoid bugs.


</details>
<details>
<summary>parse.go (6)</summary>

Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:257-331
Timestamp: 2024-10-02T22:57:30.345Z
Learning: In the GetByID method, when handling a decode error, use decodeErr in the error message to accurately report the decoding failure.


Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:257-331
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the GetByID method, when handling a decode error, use decodeErr in the error message to accurately report the decoding failure.


Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse_test.go:15-20
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Ensure to check the function signature and parameters before suggesting changes to avoid redundant recommendations.


Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse_test.go:15-20
Timestamp: 2024-07-01T15:48:33.417Z
Learning: Ensure to check the function signature and parameters before suggesting changes to avoid redundant recommendations.


Learnt from: ReneWerner87
PR: gofiber/fiber#2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The ParamsInt function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.


Learnt from: ReneWerner87
PR: gofiber/fiber#2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The ParamsInt function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.


</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)</summary>

* GitHub Check: Build (1.24.x, windows-latest)
* GitHub Check: Build (1.23.x, windows-latest)
* GitHub Check: Compare

</details>

<details>
<summary>🔇 Additional comments (14)</summary><blockquote>

<details>
<summary>parse.go (14)</summary>

`5-5`: **LGTM: Import addition supports new error handling.**

The addition of the "strconv" import is necessary to support the new error types like `strconv.ErrSyntax`, `strconv.ErrRange`, and `strconv.NumError`.

---

`18-22`: **LGTM: Function signature and documentation properly updated.**

The `ParseUint` function correctly reflects the new error-based API in both signature and documentation.

---

`25-28`: **LGTM: Function signature and documentation properly updated.**

The `ParseInt` function correctly reflects the new error-based API in both signature and documentation.

---

`31-33`: **LGTM: Function correctly uses specific function name.**

The function now correctly passes "ParseInt32" instead of the generic "ParseInt" for accurate error reporting.

---

`36-38`: **LGTM: Function correctly uses specific function name.**

The function now correctly passes "ParseInt16" instead of the generic "ParseInt" for accurate error reporting.

---

`41-43`: **LGTM: Function correctly uses specific function name.**

The function now correctly passes "ParseInt8" instead of the generic "ParseInt" for accurate error reporting.

---

`46-48`: **LGTM: Function correctly uses specific function name.**

The function now correctly passes "ParseUint32" instead of the generic "ParseUint" for accurate error reporting.

---

`51-53`: **LGTM: Function correctly uses specific function name.**

The function now correctly passes "ParseUint16" instead of the generic "ParseUint" for accurate error reporting.

---

`56-58`: **LGTM: Function correctly uses specific function name.**

The function now correctly passes "ParseUint8" instead of the generic "ParseUint" for accurate error reporting.

---

`60-76`: **LGTM: Error handling implementation is correct.**

The `parseDigits` function properly returns `strconv.ErrSyntax` for invalid characters and `strconv.ErrRange` for overflow conditions, following Go's standard error conventions.

---

`78-119`: **LGTM: Comprehensive error handling for signed integers.**

The `parseSigned` function correctly implements error handling with proper `strconv.NumError` construction that includes function name, input string, and underlying error for all error conditions.

---

`121-140`: **LGTM: Consistent error handling for unsigned integers.**

The `parseUnsigned` function maintains consistency with the signed version by properly using `strconv.NumError` for all error conditions.

---

`142-250`: **LGTM: Thorough error handling for floating-point parsing.**

The `parseFloat` function handles all parsing scenarios with appropriate error types, including syntax errors, range errors, and overflow conditions.

---

`254-256`: **LGTM: Function correctly delegates with proper function name.**

The `ParseFloat64` function properly passes "ParseFloat64" as the function name for error reporting.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACJ4Zl58KR5nRA8AM2wMMXh8DGQoSgp8PlhMWi94DCJoyAB3NGQHAWZ1Gno5MNgPbFS+GzISAHVKcgoADgB2dGRub19/IJDIDEcBSkgARgBmCY0YLshmbSwGUqqPStwi2mwGKMrO1FsUZGZFeDTZSqJOj24U9KZbK5ZAEPwkXDYChYTCQQrFFB5Ghoej4NLoSACfD4SKwiRoLzBPZwVDYbi0agebTMUH4FDxIpJeElMoVKqY+QJCTwWjfQ7FDxKXDaSL0NIkOgCNAMADWdS6WH+FEQfPw3GU4hBkDSIuJB2elQYhKUMjIpyOFDl/gcXlwyCY8WcfNwB3VF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7QOx/AdpRBxB2QeceBKASIyImDwYHB/BnJysWAPAPDCDLR+CPMpwVtAtF0/80AACnD0BaAlBaALoEATZptUFQhrsKdQg1gSJyoKEixfDfAfZL4PkCjow/REA0A2Alk8A/QVg2BSwe4yi5RAxCFShTQgDkjrQugQCjBo8MkaBa8IwE9BRq8U8es08tFW9PBKljZc9wgh4C9chyo99F8ipQpc8Rdoo7I4pHJEp2Bko0BUpT8uosofF/JlCgoCpDBvjEp1A5MeREA5N/BuJeJaA5MmtVE4TiooATwABOAAVjGGJJIG2AEAYC2GJImEJI2DQEnBHEmEmEJLQBIEnApAEA2AAAYSAeStgxgxhJw0gNg8TviqTiSeTiThxJwxgTxhxCStgNhhwNhiS0ApwBAxgNgGA0gKRaBJxiSRSySeTCTCSSAJgeThxxSLJIBhThwLS0AeSTwTwOSBBhwtgSBiSGBiTaANh3SxgtgGABA0geSJgpTCSlBCSxhRA1SbSIBIAeTaA0gZSnSxh6TCTwzaTJxIyxhdS0A0AxgqSgypwthaB6SSBVSPSpgzIDAESWAWhcBkSvw0SXCeI6A5MyB6B9AgA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings
<details open="true">
<summary>🧪 Generate unit tests</summary>

- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Create PR with unit tests
- [ ] <!-- {"checkboxId": "07f1e7d6-8a8e-4e23-9900-8731c2c87f58", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Post copyable unit tests in a comment
- [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Commit unit tests in branch `error_handling_parse_functions`

</details>

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=gofiber/utils&utm_content=137):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai auto-generate unit tests` to generate unit tests for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` or `@coderabbitai title` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Summary of Changes

Hello @ReneWerner87, 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 significantly improves the error handling of the parsing utility functions by migrating from a boolean success/failure return to a more idiomatic Go error return. This change enhances the robustness and debuggability of the parsing logic by providing specific error details, aligning the codebase with standard Go practices.

Highlights

  • Error Handling Refactor: All public and internal parsing functions (e.g., ParseUint, ParseInt, ParseFloat64, parseDigits, parseSigned, etc.) have been refactored to return a standard Go error type instead of a boolean success indicator. This provides more detailed information about parsing failures.
  • Standard Error Types Adoption: The refactored parsing functions now utilize specific error types from the strconv package, such as strconv.ErrSyntax for invalid input format and strconv.ErrRange for overflow/underflow, wrapped within strconv.NumError for richer context.
  • Test Suite Updates: The corresponding test suite (parse_test.go) has been updated across all parsing functions to assert on the returned error value, ensuring the new error handling mechanism functions as expected.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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
Copy link

codecov bot commented Jul 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.12%. Comparing base (0f60dce) to head (0df52a0).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #137      +/-   ##
==========================================
+ Coverage   97.11%   97.12%   +0.01%     
==========================================
  Files          10       10              
  Lines         727      730       +3     
==========================================
+ Hits          706      709       +3     
  Misses         14       14              
  Partials        7        7              
Flag Coverage Δ
unittests 97.12% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Copy link
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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f60dce and 49585e1.

📒 Files selected for processing (2)
  • parse.go (10 hunks)
  • parse_test.go (23 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ReneWerner87
PR: gofiber/fiber#2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: ReneWerner87
PR: gofiber/fiber#2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse.go:106-107
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `IsZero` function for `time.Time` structs in the ClickHouse storage driver was returning false even for zero value `time.Time` structs. As a result, a different verification logic was implemented to avoid bugs.
Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse.go:106-107
Timestamp: 2024-07-01T15:49:51.308Z
Learning: The `IsZero` function for `time.Time` structs in the ClickHouse storage driver was returning false even for zero value `time.Time` structs. As a result, a different verification logic was implemented to avoid bugs.
parse_test.go (12)
Learnt from: efectn
PR: gofiber/fiber#3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.
Learnt from: ReneWerner87
PR: gofiber/fiber#3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
Learnt from: norri
PR: gofiber/recipes#2701
File: clean-code/app/datasources/database/db_mock.go:13-19
Timestamp: 2024-11-23T19:50:06.387Z
Learning: In test code within `clean-code/app/datasources/database/db_mock.go`, adding safety checks like context validation, safe type assertions, and extra documentation is not necessary.
Learnt from: gaby
PR: gofiber/fiber#3170
File: ctx_test.go:1721-1724
Timestamp: 2024-10-16T12:12:30.506Z
Learning: In the Go unit tests in `ctx_test.go`, it is acceptable to use invalid CIDR notation such as `"0.0.0.1/31junk"` for testing purposes.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Unit tests in this project use testify require.
Learnt from: sixcolors
PR: gofiber/fiber#2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The project uses the testify/assert package for assertions in unit tests.
Learnt from: sixcolors
PR: gofiber/fiber#2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The project uses the testify/assert package for assertions in unit tests.
Learnt from: gaby
PR: gofiber/fiber#3056
File: middleware/encryptcookie/utils.go:22-25
Timestamp: 2024-07-02T13:29:56.992Z
Learning: The `encryptcookie_test.go` file contains unit tests that validate key lengths for both `EncryptCookie` and `DecryptCookie` functions, ensuring that invalid key lengths raise appropriate errors.
Learnt from: gaby
PR: gofiber/fiber#3056
File: middleware/encryptcookie/utils.go:22-25
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `encryptcookie_test.go` file contains unit tests that validate key lengths for both `EncryptCookie` and `DecryptCookie` functions, ensuring that invalid key lengths raise appropriate errors.
Learnt from: norri
PR: gofiber/recipes#2701
File: clean-code/app/server/server.go:14-16
Timestamp: 2024-11-23T19:50:41.765Z
Learning: In the `clean-code` example at `clean-code/app/server/server.go` using the Go Fiber framework, it's acceptable to omit production-level features like context usage and graceful shutdown handling to keep the example simple.
Learnt from: juls0730
PR: gofiber/recipes#2710
File: tableflip/main.go:61-62
Timestamp: 2024-12-01T01:15:48.126Z
Learning: In the GoFiber `tableflip` recipe (`tableflip/main.go`), the implementation matches the upstream reference implementation. Future code suggestions should consider maintaining this alignment to ensure consistency.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Build (1.24.x, windows-latest)
  • GitHub Check: Build (1.24.x, macos-13)
  • GitHub Check: Build (1.24.x, ubuntu-latest)
  • GitHub Check: Build (1.23.x, macos-latest)
  • GitHub Check: Build (1.24.x, macos-latest)
  • GitHub Check: Analyse
  • GitHub Check: Build (1.23.x, ubuntu-latest)
  • GitHub Check: Build (1.23.x, macos-13)
  • GitHub Check: Build (1.23.x, windows-latest)
  • GitHub Check: Compare
🔇 Additional comments (19)
parse_test.go (10)

29-39: Excellent migration to error-based API.

The test has been correctly updated to use the new error-based parsing API. The pattern of checking err == nil instead of a boolean success flag is idiomatic Go and provides better error information.


45-47: Proper error assertion for whitespace input.

Good use of require.Error(t, err) to assert that parsing fails for input with leading whitespace, which is the expected behavior.


56-69: Consistent error handling in benchmarks.

The benchmark properly handles errors from the new API by calling b.Fatal when parsing fails, ensuring benchmark validity while maintaining performance measurement accuracy.


103-113: Test coverage maintains comprehensive validation.

The ParseInt test correctly validates both positive and negative edge cases with proper error checking. The transition from boolean to error-based validation maintains the same test coverage quality.


121-127: Proper handling of sign-only input edge cases.

Good validation that inputs containing only "+" or "-" characters properly return errors, which is the expected behavior for invalid numeric input.


133-135: Whitespace validation correctly implemented.

The test properly verifies that leading whitespace causes parsing to fail with an error, maintaining strict input validation.


156-169: Benchmark error handling follows best practices.

All benchmark functions consistently handle errors from the updated parsing API, ensuring accurate performance measurements while preventing silent failures.


197-207: Integer type-specific parsing maintains precision.

The ParseInt32 test correctly validates range limits and error conditions for 32-bit integers, ensuring type safety is preserved in the new error-based API.


581-599: Comprehensive float parsing validation with enhanced error context.

The test provides excellent coverage of float64 parsing edge cases including scientific notation, special values, and malformed inputs. The addition of input context in error messages ("input: %s", tt.in) improves debugging capabilities.


678-702: Float32 precision and special value handling.

Excellent test coverage for float32-specific edge cases including negative zero detection and precision limits. The negzero field and corresponding validation logic properly handles IEEE 754 floating-point special cases.

parse.go (9)

5-5: Good addition of strconv import for error handling.

The strconv package import is necessary to support the new error-based API using strconv.NumError, strconv.ErrSyntax, and strconv.ErrRange.


20-22: Excellent migration to error-based API.

The function signature change from (uint64, bool) to (uint64, error) follows Go idioms and provides better error information. The delegation to parseUnsigned with proper function name is well-implemented.


26-28: Good error-based implementation for signed integers.

The ParseInt function properly delegates to parseSigned with correct parameters and function name for error reporting.


62-76: Excellent error handling in digit parsing.

The parseDigits function properly returns strconv.ErrSyntax for invalid characters and strconv.ErrRange for overflow conditions. The overflow detection using nn < n is a clever way to detect uint64 overflow.


80-119: Comprehensive signed integer parsing with proper error reporting.

The parseSigned function handles all edge cases correctly:

  • Empty input validation
  • Sign character handling
  • Overflow/underflow detection
  • Proper error construction with strconv.NumError

The logic for handling negative numbers and range checking is well-implemented.


123-140: Well-implemented unsigned integer parsing.

The parseUnsigned function correctly handles unsigned integer constraints by rejecting sign prefixes and properly checking for overflow against the maximum range.


145-250: Comprehensive float parsing with robust error handling.

The parseFloat function provides excellent coverage of floating-point parsing:

  • Sign handling
  • Integer and fractional parts
  • Scientific notation with exponent
  • Overflow detection and infinite/NaN checking
  • Proper error reporting for all failure cases

The implementation is thorough and follows IEEE 754 standards.


254-256: Clean delegation for float64 parsing.

Good implementation that delegates to the generic parseFloat function with the correct function name.


260-269: Proper float32 range validation.

The ParseFloat32 function correctly validates that the parsed float64 value fits within float32 range before conversion, ensuring no silent overflow occurs.

Copy link
Contributor

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

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 refactors the parsing functions to return an error instead of a boolean, which is a great improvement that aligns with Go's idiomatic error handling. The implementation is solid, using strconv.NumError to provide detailed error information.

I've identified a few minor issues where an incorrect function name is used when creating errors, which could lead to slightly misleading error messages. I've left suggestions to correct these. The test files have been updated correctly to reflect the new function signatures.

Overall, this is a good change that improves code quality and maintainability.

error instead of boolean return
Copy link
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

♻️ Duplicate comments (6)
parse.go (6)

20-21: LGTM! Function signature correctly updated.

The function signature properly changed to return (uint64, error) and the function name passed to parseUnsigned is correct.


26-27: LGTM! Function signature correctly updated.

The function signature properly changed to return (int64, error) and the function name passed to parseSigned is correct.


31-32: LGTM! Function names in error reporting are now correct.

All signed integer parsing functions now pass their specific function names ("ParseInt32", "ParseInt16", "ParseInt8") instead of the generic "ParseInt". This ensures accurate error reporting.

Also applies to: 36-37, 41-42


46-47: LGTM! Function names in error reporting are now correct.

All unsigned integer parsing functions now pass their specific function names ("ParseUint32", "ParseUint16", "ParseUint8") instead of the generic "ParseUint". This ensures accurate error reporting.

Also applies to: 51-52, 56-57


254-255: LGTM! Function name in error reporting is correct.

The ParseFloat64 function now passes the correct function name for accurate error reporting.


260-268: LGTM! Function properly handles float32 range checking.

The ParseFloat32 function correctly:

  • Uses the proper function name in error reporting
  • Handles overflow conditions for float32 range
  • Returns appropriate strconv.NumError for range violations
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49585e1 and bc50526.

📒 Files selected for processing (1)
  • parse.go (10 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ReneWerner87
PR: gofiber/fiber#2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: ReneWerner87
PR: gofiber/fiber#2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse.go:106-107
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `IsZero` function for `time.Time` structs in the ClickHouse storage driver was returning false even for zero value `time.Time` structs. As a result, a different verification logic was implemented to avoid bugs.
Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse.go:106-107
Timestamp: 2024-07-01T15:49:51.308Z
Learning: The `IsZero` function for `time.Time` structs in the ClickHouse storage driver was returning false even for zero value `time.Time` structs. As a result, a different verification logic was implemented to avoid bugs.
parse.go (4)
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:257-331
Timestamp: 2024-10-02T22:57:30.345Z
Learning: In the `GetByID` method, when handling a decode error, use `decodeErr` in the error message to accurately report the decoding failure.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/store.go:257-331
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the `GetByID` method, when handling a decode error, use `decodeErr` in the error message to accurately report the decoding failure.
Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse_test.go:15-20
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Ensure to check the function signature and parameters before suggesting changes to avoid redundant recommendations.
Learnt from: luk3skyw4lker
PR: gofiber/storage#1342
File: clickhouse/clickhouse_test.go:15-20
Timestamp: 2024-07-01T15:48:33.417Z
Learning: Ensure to check the function signature and parameters before suggesting changes to avoid redundant recommendations.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Analyse
  • GitHub Check: Build (1.23.x, macos-latest)
  • GitHub Check: Compare
  • GitHub Check: Build (1.24.x, macos-13)
  • GitHub Check: Build (1.24.x, ubuntu-latest)
  • GitHub Check: Build (1.23.x, macos-13)
  • GitHub Check: Build (1.24.x, macos-latest)
  • GitHub Check: Build (1.24.x, windows-latest)
  • GitHub Check: Build (1.23.x, windows-latest)
  • GitHub Check: Build (1.23.x, ubuntu-latest)
🔇 Additional comments (5)
parse.go (5)

5-5: LGTM! Proper import added for error handling.

The addition of the strconv import is necessary to support the new error-based parsing API using strconv.NumError and error constants.


60-76: LGTM! Proper error handling in digit parsing.

The parseDigits function correctly returns strconv.ErrSyntax for non-digit characters and strconv.ErrRange for overflow conditions, following Go's standard error conventions.


78-119: LGTM! Comprehensive error handling in signed integer parsing.

The parseSigned function properly handles all error conditions using strconv.NumError with correct function names, input strings, and error types. The overflow/underflow logic is sound.


121-140: LGTM! Proper error handling in unsigned integer parsing.

The parseUnsigned function correctly handles error conditions and overflow checks using strconv.NumError with accurate error reporting.


142-250: LGTM! Comprehensive floating-point parsing with proper error handling.

The parseFloat function handles all error conditions appropriately:

  • Empty input and syntax errors
  • Overflow in integer part
  • Too many fractional digits
  • Invalid exponent syntax
  • Infinite/NaN results

All errors are properly wrapped in strconv.NumError with correct function names.

error instead of boolean return
error instead of boolean return
@ReneWerner87 ReneWerner87 merged commit d9dd7af into master Jul 13, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants