Skip to content

Conversation

@Junyi-99
Copy link
Member

@Junyi-99 Junyi-99 commented Jan 6, 2026

This pull request introduces several improvements to error handling and API usability, focusing on delivering more user-friendly error messages and enhancing the authentication API. The most significant changes include improving error messages throughout the stack, adding default user-friendly messages for common error codes, and introducing a new versioned endpoint for token refresh in the authentication API.

Error handling and user experience improvements:

  • Added a mapping of error codes to user-friendly default messages in error.go, ensuring that when no detailed error is provided, a clear, helpful message is returned to the user. [1] [2]
  • Updated the error handler in server.go to use a new cleanErrorMessage function, which strips technical gRPC prefixes from error messages before returning them to clients. [1] [2]
  • Improved error messages in authentication logic (actor.go) by providing more descriptive, user-focused feedback for various authentication failures.
  • Updated the web client (apiclient.ts) to clean up error messages and provide more descriptive error toast titles based on error codes, improving the clarity of error notifications in the UI.

API enhancements and versioning:

  • Added an additional HTTP binding for the RefreshToken RPC in the authentication API, introducing a new /v2/auth/refresh endpoint alongside the existing /v1/auth/refresh. This includes all necessary changes in the protobuf definitions and generated gateway code to support the new endpoint. [1] [2] [3] [4] [5] [6] [7]

These changes collectively improve the developer and user experience by making errors easier to understand and by supporting API evolution with versioned endpoints.


Note

Enhances auth API versioning and error readability.

  • Adds /_pd/api/v2/auth/refresh as an additional binding for RefreshToken (proto updated; regenerated Go gateway and TS client files)
  • Backend HTTP error responses now strip gRPC prefixes via cleanErrorMessage in server.go
  • Introduces default user-friendly messages per ErrorCode in shared/error.go; makeErrorFunc uses them when no detail provided
  • Improves auth error messages in actor.go (token required, audience, ID format, user errors)
  • Web client (apiclient.ts) cleans gRPC prefixes and maps ErrorCode to toast titles; minor API cleanup in query/api.ts (remove unused refreshToken helper)

Written by Cursor Bugbot for commit fedfd2d. This will update automatically on new commits. Configure here.

@Junyi-99 Junyi-99 self-assigned this Jan 6, 2026
@Junyi-99 Junyi-99 moved this from Icebox to In review in Project PaperDebugger Jan 6, 2026
@Junyi-99 Junyi-99 marked this pull request as ready for review January 6, 2026 08:43
Copilot AI review requested due to automatic review settings January 6, 2026 08:43
Copy link
Contributor

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 pull request enhances error handling and introduces a versioned API endpoint for token refresh. The changes focus on providing more user-friendly error messages across the stack while maintaining backward compatibility through the addition of a /v2/auth/refresh endpoint alongside the existing v1 endpoint.

Key changes:

  • Added default user-friendly error messages for all error codes in both backend (Go) and frontend (TypeScript)
  • Implemented error message cleaning to strip technical gRPC prefixes before presenting errors to users
  • Introduced a new /v2/auth/refresh endpoint while maintaining the existing /v1/auth/refresh endpoint for backward compatibility

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/libs/shared/error.go Added default error messages map and logic to use friendly messages when no detail is provided
internal/api/server.go Added cleanErrorMessage function to strip gRPC prefixes from error messages
internal/api/actor.go Updated authentication error messages to be more user-friendly
webapp/_webapp/src/libs/apiclient.ts Added error message cleaning and error code-to-title mapping for better UI error display
proto/auth/v1/auth.proto Added additional HTTP binding for v2 refresh token endpoint
pkg/gen/api/auth/v1/auth.pb.gw.go Generated gateway code for the new v2 endpoint
pkg/gen/api/auth/v1/auth.pb.go Generated protobuf code reflecting the v2 endpoint addition
webapp/_webapp/src/pkg/gen/apiclient/auth/v1/auth_pb.ts Generated TypeScript protobuf code with v2 endpoint support

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

Junyi-99 and others added 3 commits January 6, 2026 16:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


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

Junyi-99 and others added 3 commits January 6, 2026 17:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


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

… default backend error messages and updating frontend error titles.
Copy link
Contributor

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

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


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

@Junyi-99 Junyi-99 merged commit 7bf3073 into main Jan 7, 2026
11 checks passed
@Junyi-99 Junyi-99 deleted the fix-refreshToken-and-errorHandling branch January 7, 2026 15:03
@github-project-automation github-project-automation bot moved this from In review to Done in Project PaperDebugger Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants