{"record":{"id":"a64dbd095dcfe6ef","repo":"cli/cli","slug":"couldn-t-find-oauth-token-for-q-w","errorCode":null,"errorMessage":"couldn't find oauth token for %q: %w","messagePattern":"couldn't find oauth token for %q: %w","errorType":"exception","errorClass":"CowardlyRefusalError","httpStatus":null,"severity":"error","filePath":"internal/config/migration/multi_account.go","lineNumber":118,"sourceCode":"\t// so lets avoid any confusion and say there's no migration required.\n\tif len(hostnames) == 0 {\n\t\treturn nil\n\t}\n\n\t// Otherwise let's get to the business of migrating!\n\tfor _, hostname := range hostnames {\n\t\ttokenSource, err := getToken(c, hostname)\n\t\t// If no token existed for this host we'll remove the entry from the hosts file\n\t\t// by deleting it and moving on to the next one.\n\t\tif errors.Is(err, noTokenError) {\n\t\t\t// The only error that can be returned here is the key not existing, which\n\t\t\t// we know can't be true.\n\t\t\t_ = c.Remove(append(hostsKey, hostname))\n\t\t\tcontinue\n\t\t}\n\t\t// For any other error we'll error out\n\t\tif err != nil {\n\t\t\treturn CowardlyRefusalError{fmt.Errorf(\"couldn't find oauth token for %q: %w\", hostname, err)}\n\t\t}\n\n\t\tusername, err := getUsername(c, hostname, tokenSource.token, m.Transport)\n\t\tif err != nil {\n\t\t\tissueURL := \"https://github.com/cli/cli/issues/8441\"\n\t\t\treturn CowardlyRefusalError{fmt.Errorf(\"couldn't get user name for %q please visit %s for help: %w\", hostname, issueURL, err)}\n\t\t}\n\n\t\tif err := migrateConfig(c, hostname, username); err != nil {\n\t\t\treturn CowardlyRefusalError{fmt.Errorf(\"couldn't migrate config for %q: %w\", hostname, err)}\n\t\t}\n\n\t\tif err := migrateToken(hostname, username, tokenSource); err != nil {\n\t\t\treturn CowardlyRefusalError{fmt.Errorf(\"couldn't migrate oauth token for %q: %w\", hostname, err)}\n\t\t}\n\t}\n\n\treturn nil","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/internal/config/migration/multi_account.go#L100-L136","documentation":"Error \"couldn't find oauth token for %q: %w\" thrown in cli/cli.","triggerScenarios":"Thrown at internal/config/migration/multi_account.go:118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-authenticate with `gh auth login` for that host so the migration can read the token, or set the token in the keyring/config manually before re-running."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}