probot / octokit-plugin-config

🛠️ Get/set persisted configuration using YAML/JSON files in repositories
ISC License
35 stars 16 forks source link

getConfigFile() throws error instead of returning emptyConfigResult when file does not exist #257

Open andy-crain-kr opened 2 months ago

andy-crain-kr commented 2 months ago

What happened?

When a specified file does not exist, getConfigFile() is supposed to return an emptyConfigResult object. But when the non-existent file is requested, octokit.request throws an error that has {...status: "404" }, while getConfigFile() is anticipating 404 (integer) instead of "404" (string), and so instead of returning emptyConfigResult, it instead throws the error.

What did you expect to happen?

I would expect that when a file does not exist, an emptyConfigResult object is returned.

What the problem might be

The test:

    if (error.status === 404) {
      return emptyConfigResult;
    }

should instead be:

    if (error.status === "404") {
      return emptyConfigResult;
    }
wolfy1339 commented 1 month ago

Can you provide details on your environment? It seems that in some environments, like Google Cloud Functions, status codes are returned as strings

According to the spec, status codes are supposed to be integers

Uzlopak commented 1 month ago

@andy-crain-kr

Do you use gcf?

andy-crain-kr commented 1 month ago

@wolfy1339, @Uzlopak, no this is in a self-hosted kubernetes cluster.