fix test and lint in web (#2219)

This commit is contained in:
Cytown 2026-03-31 15:50:55 +08:00 committed by GitHub
parent 31fcf55297
commit e4893d27d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 5 deletions

View file

@ -208,7 +208,10 @@ func (p *Provider) Chat(
if err != nil { if err != nil {
// Check for SSO token expiration errors and provide actionable guidance // Check for SSO token expiration errors and provide actionable guidance
if isSSOTokenError(err) { if isSSOTokenError(err) {
return nil, fmt.Errorf("bedrock converse: AWS credentials may have expired. If using AWS SSO, run 'aws sso login' to refresh: %w", err) return nil, fmt.Errorf(
"bedrock converse: AWS credentials may have expired. If using AWS SSO, run 'aws sso login' to refresh: %w",
err,
)
} }
return nil, fmt.Errorf("bedrock converse: %w", err) return nil, fmt.Errorf("bedrock converse: %w", err)
} }

View file

@ -584,12 +584,16 @@ func TestIsSSOTokenError(t *testing.T) {
}, },
{ {
name: "full SSO error message", name: "full SSO error message",
err: fmt.Errorf("get identity: get credentials: failed to refresh cached credentials, refresh cached SSO token failed, unable to refresh SSO token"), err: fmt.Errorf(
"get identity: get credentials: failed to refresh cached credentials, refresh cached SSO token failed, unable to refresh SSO token",
),
expected: true, expected: true,
}, },
{ {
name: "SSO token file missing", name: "SSO token file missing",
err: fmt.Errorf("get identity: get credentials: failed to refresh cached credentials, failed to read cached SSO token file, open ~/.aws/sso/cache/abc123.json: no such file or directory"), err: fmt.Errorf(
"get identity: get credentials: failed to refresh cached credentials, failed to read cached SSO token file, open ~/.aws/sso/cache/abc123.json: no such file or directory",
),
expected: true, expected: true,
}, },
} }

View file

@ -68,6 +68,7 @@ func resetGatewayTestState(t *testing.T) {
originalRestartGracePeriod := gatewayRestartGracePeriod originalRestartGracePeriod := gatewayRestartGracePeriod
originalRestartForceKillWindow := gatewayRestartForceKillWindow originalRestartForceKillWindow := gatewayRestartForceKillWindow
originalRestartPollInterval := gatewayRestartPollInterval originalRestartPollInterval := gatewayRestartPollInterval
t.Setenv("PICOCLAW_HOME", t.TempDir())
t.Cleanup(func() { t.Cleanup(func() {
gatewayHealthGet = originalHealthGet gatewayHealthGet = originalHealthGet
gatewayRestartGracePeriod = originalRestartGracePeriod gatewayRestartGracePeriod = originalRestartGracePeriod