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

fix(api): visible and better error when fetching secrets 404s #5277

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 33 additions & 4 deletions core/src/cloud/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { add } from "date-fns"
import { LogLevel } from "../logger/logger"
import { makeAuthHeader } from "./auth"
import { StringMap } from "../config/common"
import chalk from "chalk"

const gardenClientName = "garden-core"
const gardenClientVersion = getPackageVersion()
Expand Down Expand Up @@ -772,13 +773,41 @@ export class CloudApi {
if (!(err instanceof GotHttpError)) {
throw err
}
// This happens if an environment or project does not exist
if (err.response.statusCode === 404) {
log.debug(dedent`
No secrets were received from ${distroName}.
const errorHeaderMsg = chalk.red(`Unable to read secrets from ${distroName}.`)
const errorDetailMsg = chalk.white(dedent`
Either the environment ${chalk.bold.whiteBright(environmentName)} does not exist in ${distroName},
or no project matches the project ID ${chalk.bold.whiteBright(
projectId
)} in your project level garden.yml file.

Either the environment ${environmentName} does not exist in ${distroName}, or no project with the id in your project configuration exists in ${distroName}.
💡Suggestion:

Please visit ${this.domain} to review the environments and projects currently in the system.
Visit ${chalk.underline(this.domain)} to review existing environments and projects.

First check whether an environment with name ${environmentName} exists for this project. You
can view the list of environments and the project ID on the project's Settings page.

${chalk.bold.whiteBright(
"If the environment does not exist"
)}, you can either create one from the Settings page or update
the environments in your project level garden.yml config to match one that already exists.

${chalk.bold.whiteBright(
"If a project with this ID does not exist"
)}, it's likely because the ID has been changed in the
project level garden.yml config file or the project has been deleted from ${distroName}.

Either update the ID in the project level garden.yml config file to match one of an
existing project or import a new project from the Projects page and replace the ID in your
project configuration with the ID of the new project.
`)

log.error(dedent`
${errorHeaderMsg}

${errorDetailMsg}\n
`)
} else {
throw err
Expand Down