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
Copy link
Copy Markdown
Member

@erunion erunion commented May 8, 2026

🚥 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.

Copy link
Copy Markdown

@flinehan flinehan left a comment

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
Copy link
Copy Markdown
Member Author

erunion commented May 11, 2026

🎉 This PR is included in version 10.7.1-next.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

enhancement New feature or request released on @next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants