fix: recover from expired enterprise auth on remote config load (#31661)
This commit is contained in:
@@ -94,6 +94,18 @@ export function FormatError(input: unknown): string | undefined {
|
||||
return stringField(configFrontmatter, "message") ?? ""
|
||||
}
|
||||
|
||||
// ConfigRemoteAuthError: { url: string, remote: string }
|
||||
const remoteAuth = configData(input, "ConfigRemoteAuthError")
|
||||
if (remoteAuth) {
|
||||
const url = stringField(remoteAuth, "url")
|
||||
const remote = stringField(remoteAuth, "remote")
|
||||
return [
|
||||
`Failed to load remote config${remote ? ` from ${remote}` : ""}: the server returned a login page instead of JSON.`,
|
||||
`Authentication is missing or has expired (the endpoint is likely behind an SSO or identity-aware proxy).`,
|
||||
...(url ? [`Run \`opencode auth login ${url}\` to re-authenticate.`] : []),
|
||||
].join("\n")
|
||||
}
|
||||
|
||||
// ConfigInvalidError: { path?: string, message?: string, issues?: Array<{ message: string, path: string[] }> }
|
||||
const configInvalid = configData(input, "ConfigInvalidError")
|
||||
if (configInvalid) {
|
||||
|
||||
Reference in New Issue
Block a user