File tree Expand file tree Collapse file tree
lib/credentials/token-service-accounts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,15 +188,26 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
188188 )
189189 } catch ( error ) {
190190 logger . error ( `[${ requestId } ] Service account token error:` , error )
191- // Classified provider outages are infra failures, not bad credentials.
192- if (
193- error instanceof TokenServiceAccountValidationError &&
194- error . code === 'provider_unavailable'
195- ) {
196- return NextResponse . json (
197- { error : 'Credential provider is temporarily unavailable' } ,
198- { status : 502 }
199- )
191+ if ( error instanceof TokenServiceAccountValidationError ) {
192+ // Classified provider outages are infra failures, not bad credentials.
193+ if ( error . code === 'provider_unavailable' ) {
194+ return NextResponse . json (
195+ { error : 'Credential provider is temporarily unavailable' } ,
196+ { status : 502 }
197+ )
198+ }
199+ // A stored host that no longer resolves is a configuration failure —
200+ // surface the code so runtime consumers can say "check the host"
201+ // instead of a generic auth error.
202+ if ( error . code === 'site_not_found' ) {
203+ return NextResponse . json (
204+ {
205+ code : error . code ,
206+ error : 'Credential host not found — reconnect the credential with a valid host' ,
207+ } ,
208+ { status : 400 }
209+ )
210+ }
200211 }
201212 return NextResponse . json ( { error : 'Failed to get service account token' } , { status : 401 } )
202213 }
Original file line number Diff line number Diff line change @@ -63,7 +63,9 @@ export async function fetchProvider(
6363 return await fetch ( url , { ...init , signal : AbortSignal . timeout ( PROVIDER_FETCH_TIMEOUT_MS ) } )
6464 } catch ( error ) {
6565 const causeCode = ( error as { cause ?: { code ?: unknown } } ) ?. cause ?. code
66- if ( options ?. dnsFailureCode && ( causeCode === 'ENOTFOUND' || causeCode === 'EAI_AGAIN' ) ) {
66+ // Only ENOTFOUND proves the host doesn't exist; EAI_AGAIN is a transient
67+ // resolver failure and stays provider_unavailable.
68+ if ( options ?. dnsFailureCode && causeCode === 'ENOTFOUND' ) {
6769 throw new TokenServiceAccountValidationError ( options . dnsFailureCode , 400 , {
6870 step,
6971 reason : options . dnsFailureReason ?? 'host does not resolve' ,
You can’t perform that action at this time.
0 commit comments