Skip to content

fix(cli): return after printing help in creds command - #6203

Open
lingyicute wants to merge 1 commit into
SunshineStream:masterfrom
lingyicute:master
Open

lingyicute wants to merge 1 commit into
SunshineStream:masterfrom
lingyicute:master

Conversation

@lingyicute

Copy link
Copy Markdown

Description

Return early from args::creds() after calling help(name) when fewer than two arguments are provided or either argument is "help".

Previously, args::creds() called help(name) without returning and fell through to http::save_user_creds(config::sunshine.credentials_file, argv[0], argv[1]), which dereferenced nullptr (or read past argv) when arguments were missing and overwrote stored credentials when "help" was passed.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

  • Added CredsCommandTest unit tests in tests/unit/test_entry_handler.cpp covering missing arguments (argc == 0 and argc == 1), explicit help arguments, and valid credential saving.
  • Verified with a standalone C++23 harness compiled with g++ on Linux that unpatched args::creds throws std::logic_error on missing arguments and writes credentials on help, while the patched version passes all assertions.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

Signed-off-by: lingyicute <xlyxinglinyi@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant