Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading error message when an invalid NETLIFY_AUTH_TOKEN is provided #6736

Open
zetaraku opened this issue Jun 27, 2024 · 0 comments
Open
Labels
type: bug code to address defects in shipped code

Comments

@zetaraku
Copy link

zetaraku commented Jun 27, 2024

Describe the bug

A confusing error message is shown when running netlify deploy with an invalid NETLIFY_AUTH_TOKEN:

»   Error: Site not found. Please rerun "netlify link"

I did some inspection and found out that a TextHTTPError: Unauthorized error is thrown from line 6 instead of expected line 11 in this file:

export const getSiteByName = async (api, siteName) => {
try {
const sites = await api.listSites({ name: siteName, filter: 'all' })
// @ts-expect-error TS(7006) FIXME: Parameter 'filteredSite' implicitly has an 'any' t... Remove this comment to see the full error message
const siteFoundByName = sites.find((filteredSite) => filteredSite.name === siteName)
if (!siteFoundByName) {
throw Error
}
return siteFoundByName
} catch {
error('Site not found. Please rerun "netlify link"')
}
}

See also:

Steps to reproduce

  1. Run netlify deploy with a valid NETLIFY_SITE_ID and an invalid NETLIFY_AUTH_TOKEN.

Configuration

[build]
  command = "npm run build"
  publish = "./dist/"

Environment

System:
  OS: Windows 10 10.0.19045
  CPU: (8) x64 Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz
  Memory: 1.44 GB / 11.84 GB
Binaries:
  Node: 20.12.0 - C:\Program Files\nodejs\node.EXE      
  Yarn: 1.22.19 - ~\.yarn\bin\yarn.CMD
  npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
  pnpm: 8.15.5 - C:\Program Files\nodejs\pnpm.CMD
@zetaraku zetaraku added the type: bug code to address defects in shipped code label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

1 participant