Skip to content

refactor: migrate errors.As to errors.AsType (Go 1.26 generics)#2959

Open
Piwriw wants to merge 1 commit into
e2b-dev:mainfrom
Piwriw:refactor/errors-as-optimization
Open

refactor: migrate errors.As to errors.AsType (Go 1.26 generics)#2959
Piwriw wants to merge 1 commit into
e2b-dev:mainfrom
Piwriw:refactor/errors-as-optimization

Conversation

@Piwriw

@Piwriw Piwriw commented Jun 9, 2026

Copy link
Copy Markdown

refactor: migrate errors.As to errors.AsType (Go 1.26 generics)

@cla-bot

cla-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @Piwriw on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@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

Using status.FromError directly on the error in packages/shared/pkg/storage/storage_google.go breaks detection of wrapped gRPC errors because status.FromError only performs a direct type assertion and does not traverse the error chain, which is a regression from the original errors.As implementation. To preserve the unwrapping behavior, use errors.AsType with the grpcStatusProvider interface.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +680 to 682
if s, ok := status.FromError(err); ok {
return s.Code() == codes.ResourceExhausted
}

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.

high

Using status.FromError directly on the error breaks detection of wrapped gRPC errors because status.FromError only performs a direct type assertion and does not traverse the error chain. This is a regression from the original errors.As implementation which correctly unwrapped the error chain. To preserve the unwrapping behavior while adopting the new pattern, use errors.AsType with the grpcStatusProvider interface.

	type grpcStatusProvider interface {
		GRPCStatus() *status.Status
	}
	if se, ok := errors.AsType[grpcStatusProvider](err);"ok {
		return se.GRPCStatus().Code() == codes.ResourceExhausted
	}
References
  1. Focus on error handling and correctness issues, skipping style/nit comments. (link)

@Piwriw Piwriw force-pushed the refactor/errors-as-optimization branch from ec0fddf to 66ac0ab Compare June 9, 2026 10:40
@cla-bot

cla-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @Piwriw on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@Piwriw Piwriw closed this Jun 9, 2026
@Piwriw Piwriw reopened this Jun 9, 2026
@Piwriw Piwriw closed this Jun 9, 2026
@Piwriw Piwriw reopened this Jun 9, 2026
@Piwriw Piwriw closed this Jun 9, 2026
@Piwriw Piwriw reopened this Jun 9, 2026
@Piwriw

Piwriw commented Jun 9, 2026

Copy link
Copy Markdown
Author

/cla recheck

@Piwriw

Piwriw commented Jun 9, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Jun 9, 2026
@cla-bot

cla-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

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.

1 participant