Skip to content

fix: http user input error#7389

Merged
n1ru4l merged 4 commits into
mainfrom
fix-user-input-error
Dec 8, 2025
Merged

fix: http user input error#7389
n1ru4l merged 4 commits into
mainfrom
fix-user-input-error

Conversation

@n1ru4l

@n1ru4l n1ru4l commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Background

An increased amount of security researchers penetrate our API and invalid user input errors where reported as 500 errors on sentry.

Description

Closes https://linear.app/the-guild/issue/CONSOLE-1621/hive-service-fastify-sdk-error-handling

Changes the error handler to

  • work the same whether sentry error reporting is enabled or not
  • only report non 4XX errors and treat them as 500 errors

@n1ru4l n1ru4l marked this pull request as draft December 8, 2025 13:31
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @n1ru4l, 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 refactors the Fastify error handling mechanism to accurately differentiate between client-side (4XX) and server-side (5XX) errors. Previously, client input errors were being miscategorized and reported as internal server errors in Sentry. The updated handler ensures that only genuine server errors are logged to Sentry, while also providing consistent and appropriate HTTP responses for all error types, irrespective of Sentry's configuration.

Highlights

  • Improved Error Handling: Client-side 4XX errors are no longer incorrectly reported as 500 internal server errors to Sentry, preventing misleading error reports.
  • Consistent Error Responses: The error handler now provides predictable and appropriate HTTP error responses, regardless of whether Sentry error reporting is enabled or not.
  • Refactored Error Handler: The Sentry-specific error handler has been generalized and renamed to http-error-handler, now accepting an option to enable/disable Sentry integration for more flexible control.
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.

@n1ru4l n1ru4l changed the title fix: user input error fix: http user input error Dec 8, 2025

@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 refactors the error handling logic to correctly handle 4xx errors and prevent them from being reported as 500 internal server errors, especially when Sentry is enabled. The changes unify the error handling flow, making it consistent whether Sentry is used or not. The introduction of http-error-handler.ts is a good structural improvement. My main feedback is to ensure the API error responses are consistent in format for both 4xx and 500 status codes.

Comment thread packages/services/service-common/src/http-error-handler.ts Outdated
@github-actions

github-actions Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
hive 8.13.0-alpha-20251208134837-f7d2eb8af6615512c52e8a3243b3a351f6d1481e npm ↗︎ unpkg ↗︎

@github-actions

github-actions Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

📚 Storybook Deployment

The latest changes are available as preview in: https://pr-7389.hive-storybook.pages.dev

Comment on lines +12 to +15
if (err.statusCode && err.statusCode < 500) {
req.log.warn(err.message);
void reply.status(err.statusCode).send(err.message);
return;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Anything with status code below 500 is an user input error and we should not report it.

@github-actions

github-actions Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

💻 Website Preview

The latest changes are available as preview in: https://pr-7389.hive-landing-page.pages.dev

@github-actions

github-actions Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: f7d2eb8af6615512c52e8a3243b3a351f6d1481e

Comment thread .changeset/yummy-ears-accept.md Outdated
@theguild-bot theguild-bot temporarily deployed to development December 8, 2025 14:58 Inactive
@n1ru4l n1ru4l marked this pull request as ready for review December 8, 2025 15:11
@n1ru4l n1ru4l merged commit a9a3e5f into main Dec 8, 2025
25 checks passed
@n1ru4l n1ru4l deleted the fix-user-input-error branch December 8, 2025 15:12
adambenhassen pushed a commit that referenced this pull request Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants