Skip to content

fix: improving our error messages when API keys aren't supplied - #1463

Merged
erunion merged 4 commits into
nextfrom
fix/bad-api-key-clarity
May 11, 2026
Merged

fix: improving our error messages when API keys aren't supplied#1463
erunion merged 4 commits into
nextfrom
fix/bad-api-key-clarity

Conversation

@erunion

@erunion erunion commented May 8, 2026

Copy link
Copy Markdown
Member
馃殽 Resolves CX-2967

馃О Changes

This overhauls how our --key flag validation is run on each command that uses it to clean up a couple cases where you get back confusing API error messages when the API key is invalid:

  • If you supplied --key='' the error message you get back would be a hard 500 with "An unknown error has occurred.".
  • if you didn't supply --key at all you'd get back a ReadMe Refactored error message of "Your project needs to be upgraded to ReadMe Refactored to make this request.".

馃К QA & Testing

No API key supplied:

$ ./bin/dev.js openapi upload --key="" ~/Desktop/petstore.json

Parsing --key 
	No project API key was specified.
See more help with --help

When no API key is supplied and you're in a CI environment:

$ TEST_RDME_CI=true ./bin/dev.js openapi upload ~/Desktop/petstore.json

No project API key was provided. Please provide one with `--key` or the `RDME_API_KEY` or `README_API_KEY` environment variables.

@erunion erunion added the enhancement New feature or request label May 8, 2026
@erunion
erunion marked this pull request as ready for review May 8, 2026 18:51
Comment thread README.md

## Authentication

For local CLI usage with a single project, you can authenticate `rdme` to your ReadMe project using `rdme login`. Once you follow the prompts and are successfully authenticated, your API key will be saved to a local configuration file (`~/.config/configstore/rdme-production.json`) and you won't have to provide the `--key` option to commands that require it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated these docs because --key is a flag, not an option:

Image

expect(result).toMatchSnapshot();
});

describe('API key validation', () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are well covered already in lib/hooks.test.ts but I figured it would be worth having them in at least one other test to ensure that the whole flow works as intended.

Comment thread test/helpers/oclif.ts
return captureOutput<string>(() => Command.run(args, oclifConfig), { testNodeEnv });
return captureOutput<string>(
async () => {
await oclifConfig.runHook('prerun', { argv: args ?? [], Command });

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Command.run just executes the commands executor we need to manually invoke these hooks here for our unit test command builder.

@flinehan flinehan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my limited knowledge of this codebase these changes look good to me.

@erunion
erunion merged commit a381af0 into next May 11, 2026
9 checks passed
@erunion
erunion deleted the fix/bad-api-key-clarity branch May 11, 2026 16:03
erunion pushed a commit that referenced this pull request May 11, 2026
## [10.7.1-next.3](v10.7.1-next.2...v10.7.1-next.3) (2026-05-11)

### Bug Fixes

* improving our error messages when API keys aren't supplied ([#1463](#1463)) ([a381af0](a381af0))

[skip ci]
@erunion

erunion commented May 11, 2026

Copy link
Copy Markdown
Member Author

馃帀 This PR is included in version 10.7.1-next.3 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

erunion pushed a commit that referenced this pull request May 13, 2026
# [10.8.0](v10.7.0...v10.8.0) (2026-05-13)

### Bug Fixes

* **gha:** argument parsing when using quotations ([#1461](#1461)) ([ed4a6ed](ed4a6ed)), closes [#1374](#1374)
* improving our error messages when API keys aren't supplied ([#1463](#1463)) ([a381af0](a381af0))
* mistyped type guard ([25fde5c](25fde5c))
* updating our transitive `ip-address` dependency ([#1459](#1459)) ([ec04846](ec04846))

### Features

* improved messaging around inferred OpenAPI slugs when `--slug` is missing ([#1465](#1465)) ([ee37d2e](ee37d2e))

[skip ci]
@erunion

erunion commented May 13, 2026

Copy link
Copy Markdown
Member Author

馃帀 This PR is included in version 10.8.0 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

github-actions Bot added a commit to step-security/readmeio-rdme that referenced this pull request Jul 6, 2026
# [10.8.0](readmeio/rdme@v10.7.0...v10.8.0) (2026-05-13)

### Bug Fixes

* **gha:** argument parsing when using quotations ([#1461](readmeio/rdme#1461)) ([ed4a6ed](readmeio/rdme@ed4a6ed)), closes [#1374](readmeio/rdme#1374)
* improving our error messages when API keys aren't supplied ([#1463](readmeio/rdme#1463)) ([a381af0](readmeio/rdme@a381af0))
* mistyped type guard ([25fde5c](readmeio/rdme@25fde5c))
* updating our transitive `ip-address` dependency ([#1459](readmeio/rdme#1459)) ([ec04846](readmeio/rdme@ec04846))

### Features

* improved messaging around inferred OpenAPI slugs when `--slug` is missing ([#1465](readmeio/rdme#1465)) ([ee37d2e](readmeio/rdme@ee37d2e))

[skip ci]
github-actions Bot added a commit to step-security/readmeio-rdme that referenced this pull request Jul 6, 2026
# [10.8.0](readmeio/rdme@v10.7.0...v10.8.0) (2026-05-13)

### Bug Fixes

* **gha:** argument parsing when using quotations ([#1461](readmeio/rdme#1461)) ([ed4a6ed](readmeio/rdme@ed4a6ed)), closes [#1374](readmeio/rdme#1374)
* improving our error messages when API keys aren't supplied ([#1463](readmeio/rdme#1463)) ([a381af0](readmeio/rdme@a381af0))
* mistyped type guard ([25fde5c](readmeio/rdme@25fde5c))
* updating our transitive `ip-address` dependency ([#1459](readmeio/rdme#1459)) ([ec04846](readmeio/rdme@ec04846))

### Features

* improved messaging around inferred OpenAPI slugs when `--slug` is missing ([#1465](readmeio/rdme#1465)) ([ee37d2e](readmeio/rdme@ee37d2e))

[skip ci]
github-actions Bot added a commit to step-security/readmeio-rdme that referenced this pull request Jul 6, 2026
# [10.8.0](readmeio/rdme@v10.7.0...v10.8.0) (2026-05-13)

### Bug Fixes

* **gha:** argument parsing when using quotations ([#1461](readmeio/rdme#1461)) ([ed4a6ed](readmeio/rdme@ed4a6ed)), closes [#1374](readmeio/rdme#1374)
* improving our error messages when API keys aren't supplied ([#1463](readmeio/rdme#1463)) ([a381af0](readmeio/rdme@a381af0))
* mistyped type guard ([25fde5c](readmeio/rdme@25fde5c))
* updating our transitive `ip-address` dependency ([#1459](readmeio/rdme#1459)) ([ec04846](readmeio/rdme@ec04846))

### Features

* improved messaging around inferred OpenAPI slugs when `--slug` is missing ([#1465](readmeio/rdme#1465)) ([ee37d2e](readmeio/rdme@ee37d2e))

[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants