Skip to content

📒 docs: Update utils guide documentation #3575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2025

Conversation

ReneWerner87
Copy link
Member

Summary

  • correct signature for generic Convert function
  • clarify examples for Convert

Testing

  • make test

https://chatgpt.com/codex/tasks/task_e_6872df0650d483268ea5b8635a009233

@Copilot Copilot AI review requested due to automatic review settings July 12, 2025 22:29
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner July 12, 2025 22:29
Copy link
Contributor

coderabbitai bot commented Jul 12, 2025

Warning

Rate limit exceeded

@ReneWerner87 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f4eac17 and b661045.

📒 Files selected for processing (2)
  • docs/api/ctx.md (1 hunks)
  • docs/guide/utils.md (4 hunks)

Walkthrough

Documentation for the generic Convert function was updated to reflect a change in its return type from a pointer to a value. Example code was corrected for syntax, formatting, and proper type usage. No changes were made to implementation code; all updates are limited to documentation and usage examples.

Changes

File(s) Change Summary
docs/guide/utils.md Updated Convert function signature in docs; fixed example code syntax, added missing brace and return, improved formatting.
docs/whats_new.md Corrected example usage of Convert to use the correct type parameter (int instead of string).

Suggested labels

📒 Documentation, v3

Suggested reviewers

  • gaby
  • sixcolors

Poem

In docs we trust, with types anew,
The pointer’s gone—just value, true!
Examples fixed, with braces tight,
Type mismatches now set right.
A hop, a skip, a doc update—
This rabbit thinks it’s looking great! 🐇✨


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • 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 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 for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in 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 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 focuses on enhancing the accuracy and readability of the documentation for the generic Convert utility function. It addresses an incorrect return type in the function's signature and refines associated code examples to ensure they are syntactically correct and clearly illustrate proper usage, including a specific type parameter correction in a whats_new entry.

Highlights

  • Documentation Correction: Corrected the documented signature of the generic Convert function in docs/guide/utils.md to reflect that it returns a direct value (T) rather than a pointer (*T).
  • Example Clarity: Improved the clarity and correctness of the Convert function's usage examples in docs/guide/utils.md by fixing syntax (e.g., adding missing closing parentheses) and ensuring examples are complete with return nil.
  • Type Parameter Correction: Updated an example in docs/whats_new.md to use the correct type parameter (int) for the Convert function when demonstrating conversion with strconv.Atoi, ensuring type consistency.
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.

Copy link
Contributor

@Copilot Copilot AI left a comment

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 the generic signature of the Convert function in the docs and updates related examples for consistency.

  • Updates the Convert call in whats_new.md to use the correct type parameter (int).
  • Changes the Convert signature in utils.md to return (T, error) instead of (*T, error).
  • Fixes the example code blocks in utils.md by closing handlers properly and adding a return nil in one handler.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
docs/whats_new.md Switched fiber.Convert[string] to fiber.Convert[int] in example.
docs/guide/utils.md Updated Convert signature to (T, error) and adjusted example blocks.
Comments suppressed due to low confidence (2)

docs/guide/utils.md:23

  • [nitpick] The example handler for /id/:id closes without returning a value, which may confuse readers. Consider adding a return statement (e.g., return c.SendString(parsedValue.String())) to show how to handle the conversion result.
})

docs/guide/utils.md:16

  • [nitpick] The Convert signature now includes a variadic defaultValue parameter, but the examples don’t show its usage. Consider adding an example that passes a default value to demonstrate its behavior when conversion fails.
func Convert[T any](value string, converter func(string) (T, error), defaultValue ...T) (T, error)

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 corrects the signature and examples for the generic Convert function in the documentation. The changes are good, but I've found a couple of issues in the example code snippets that would cause them to fail compilation. My suggestions will make the examples valid and clearer for users. Please take a look.

Comment on lines +22 to +23
fiber.Convert(c.Params("id"), uuid.Parse) // UUID(bb70ab33-d455-4a03-8d78-d3c1dacae9ff), nil
})
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This handler is missing a return statement, which makes the Go code in this example invalid. A function with a return type of error must end with a return statement.

To make the example correct and more robust, you should add return nil and also handle the returned values from fiber.Convert, even if it's just by assigning them to the blank identifier _.

Suggested change
fiber.Convert(c.Params("id"), uuid.Parse) // UUID(bb70ab33-d455-4a03-8d78-d3c1dacae9ff), nil
})
_, _ = fiber.Convert(c.Params("id"), uuid.Parse) // UUID(bb70ab33-d455-4a03-8d78-d3c1dacae9ff), nil
return nil
})

Comment on lines 27 to 29
fiber.Convert(c.Query("id"), mongo.ParseObjectID) // objectid(65f6f54221fb90e6a6b76db7), nil
fiber.Convert(c.Query("id"), uuid.Parse) // uuid.Nil, error(cannot parse given uuid)
fiber.Convert(c.Query("id"), uuid.Parse, mongo.NewObjectID) // new object id generated and return nil as error.
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The return values of fiber.Convert are not being used, which will result in a compilation error: function call ... used as value. To fix this and to show that the return values are intentionally being ignored in this example, you should assign them to the blank identifier _.

Suggested change
fiber.Convert(c.Query("id"), mongo.ParseObjectID) // objectid(65f6f54221fb90e6a6b76db7), nil
fiber.Convert(c.Query("id"), uuid.Parse) // uuid.Nil, error(cannot parse given uuid)
fiber.Convert(c.Query("id"), uuid.Parse, mongo.NewObjectID) // new object id generated and return nil as error.
_, _ = fiber.Convert(c.Query("id"), mongo.ParseObjectID) // objectid(65f6f54221fb90e6a6b76db7), nil
_, _ = fiber.Convert(c.Query("id"), uuid.Parse) // uuid.Nil, error(cannot parse given uuid)
_, _ = fiber.Convert(c.Query("id"), uuid.Parse, mongo.NewObjectID) // new object id generated and return nil as error.

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: 1

🧹 Nitpick comments (1)
docs/guide/utils.md (1)

26-31: Consider showing error handling for pedagogical completeness.

You already return nil, but demonstrating typical error handling would be clearer:

if _, err := fiber.Convert(c.Query("id"), uuid.Parse); err != nil {
    // handle err ...
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d3229a and f4eac17.

📒 Files selected for processing (2)
  • docs/guide/utils.md (1 hunks)
  • docs/whats_new.md (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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`.
docs/whats_new.md (7)
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: sixcolors
PR: gofiber/fiber#3446
File: docs/middleware/logger.md:44-44
Timestamp: 2025-05-13T00:19:16.407Z
Learning: In documentation files for the Fiber framework, code examples are often partial and don't repeat import statements that were shown in earlier examples, focusing instead on demonstrating specific usage patterns.
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
Learnt from: mdelapenya
PR: gofiber/fiber#3434
File: docs/api/services.md:39-43
Timestamp: 2025-05-07T13:07:33.899Z
Learning: When documenting Go interface methods in the Fiber project, avoid showing method signatures with the interface type as the receiver (e.g., `func (d *Service) Method()`) since interfaces cannot be used as receivers in Go. Instead, show just the method signature without a receiver or use a placeholder implementation name.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/config.go:122-122
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.
Learnt from: sixcolors
PR: gofiber/fiber#3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.
Learnt from: gaby
PR: gofiber/fiber#3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
🔇 Additional comments (2)
docs/guide/utils.md (1)

16-17: Signature line now correct — good catch.

The updated return type (T, error) matches the current implementation in fiber/utils.go.
No further action needed.

docs/whats_new.md (1)

710-712: Type parameter fix looks good.

Switching to Convert[int] removes the previous type mismatch with strconv.Atoi.

Comment on lines 21 to +23
app.Get("/id/:id", func(c fiber.Ctx) error {
fiber.Convert(c.Params("id"), uuid.Parse) // UUID(bb70ab33-d455-4a03-8d78-d3c1dacae9ff), nil

fiber.Convert(c.Params("id"), uuid.Parse) // UUID(bb70ab33-d455-4a03-8d78-d3c1dacae9ff), nil
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handler still lacks a return → won’t compile.

app.Get requires func(c fiber.Ctx) error.
The function body ends without returning an error, so the example will not compile/go-vet.

 app.Get("/id/:id", func(c fiber.Ctx) error {
     fiber.Convert(c.Params("id"), uuid.Parse)                   // UUID(...), nil
-})
+    return nil
+})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
app.Get("/id/:id", func(c fiber.Ctx) error {
fiber.Convert(c.Params("id"), uuid.Parse) // UUID(bb70ab33-d455-4a03-8d78-d3c1dacae9ff), nil
fiber.Convert(c.Params("id"), uuid.Parse) // UUID(bb70ab33-d455-4a03-8d78-d3c1dacae9ff), nil
})
app.Get("/id/:id", func(c fiber.Ctx) error {
fiber.Convert(c.Params("id"), uuid.Parse) // UUID(bb70ab33-d455-4a03-8d78-d3c1dacae9ff), nil
return nil
})
🤖 Prompt for AI Agents
In docs/guide/utils.md around lines 21 to 23, the example handler function for
app.Get does not return an error as required by the function signature. To fix
this, add a return statement that returns an error value, such as nil or an
appropriate error, at the end of the handler function to ensure it compiles
correctly.

@ReneWerner87 ReneWerner87 enabled auto-merge (squash) July 12, 2025 22:32
@ReneWerner87 ReneWerner87 disabled auto-merge July 12, 2025 22:32
@ReneWerner87 ReneWerner87 enabled auto-merge (squash) July 12, 2025 22:33
@ReneWerner87 ReneWerner87 disabled auto-merge July 12, 2025 22:33
@gaby gaby added this to v3 Jul 13, 2025
@gaby gaby added this to the v3 milestone Jul 13, 2025
@gaby gaby changed the title Fix docs generics 📒 docs: Update generics documentation Jul 13, 2025
@gaby gaby changed the title 📒 docs: Update generics documentation 📒 docs: Update utils guide documentation Jul 13, 2025
@ReneWerner87 ReneWerner87 merged commit 0d03102 into main Jul 13, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this to Done in v3 Jul 13, 2025
@ReneWerner87 ReneWerner87 deleted the codex/2025-07-12-22-29-30 branch July 30, 2025 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants