Skip to content

Conversation

@jakubno
Copy link
Member

@jakubno jakubno commented Oct 15, 2025

No description provided.

@jakubno jakubno added the improvement Improvement for current functionality label Oct 15, 2025
@linear
Copy link

linear bot commented Oct 15, 2025

@jakubno jakubno force-pushed the remove-access-token-from-entgo-eng-3185 branch 2 times, most recently from ce1250e to 267b66c Compare October 15, 2025 11:58
@jakubno jakubno force-pushed the remove-access-token-from-entgo-eng-3185 branch from 9d75dd9 to af512a3 Compare October 27, 2025 10:28
@jakubno jakubno marked this pull request as ready for review October 27, 2025 21:19
@@ -0,0 +1,6 @@
-- name: ValidateEnvBuilds :one
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're not using the results, we might be able to swap this for :exec and just check for an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

It wouldn't return an error

Comment on lines +38 to 52
func ValidateAccessToken(ctx context.Context, db *client.Client, accessToken string) bool {
hashedToken, err := keys.VerifyKey(keys.AccessTokenPrefix, accessToken)
if err != nil {
return false
}

exists, err := db.AccessToken.Query().Where(accesstoken.AccessTokenHash(hashedToken)).Exist(ctx)
_, err = db.GetUserIDFromAccessToken(ctx, hashedToken)
if err != nil {
log.Printf("Error while checking access token: %s\n", err.Error())

return false
}

return exists
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be easy to get some tests around this, via testcontainers

if err != nil {
return false, err
}
if errors.Is(err, sql.ErrNoRows) {
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a helper dberrors.IsNoRowsError


e, err := db.Env.Query().Where(
env.ID(envID),
env.HasBuildsWith(envbuild.StatusEQ(envbuild.StatusWaiting)),
Copy link
Contributor

Choose a reason for hiding this comment

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

the status code filter is missing now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants