Skip to content

Conversation

droidmonkey
Copy link
Member

Testing strategy

Updated test cases to account for password prompt being written to stderr in quiet mode

Type of change

  • ✅ Bug fix (non-breaking change that fixes an issue)

@droidmonkey droidmonkey added this to the v2.7.11 milestone Aug 20, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issue #12402 by ensuring that database unlock errors are written to stderr even when CLI commands are run in quiet mode. Previously, these password prompts and error messages were being suppressed completely in quiet mode, making debugging difficult.

Key Changes:

  • Updated CLI utility to always write database unlock errors to stderr regardless of quiet mode setting
  • Updated all test cases to expect password prompts on stderr even in quiet mode

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/cli/Utils.cpp Modified to always write database unlock errors to stderr, removing quiet mode suppression
tests/TestCli.cpp Updated test assertions to expect "Enter password to unlock" prompts on stderr in quiet mode tests

@@ -123,7 +123,7 @@ namespace Utils
const QString& yubiKeySlot,
bool quiet)
Copy link
Preview

Copilot AI Aug 20, 2025

Choose a reason for hiding this comment

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

The code change removes the quiet mode logic but the quiet parameter is still present in the function signature. Consider removing the unused parameter or documenting why it's kept for future use to avoid confusion.

Suggested change
bool quiet)
const QString& yubiKeySlot)

Copilot uses AI. Check for mistakes.

Copy link

codecov bot commented Aug 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.20%. Comparing base (8d59090) to head (01a1982).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12403      +/-   ##
===========================================
+ Coverage    64.19%   64.20%   +0.01%     
===========================================
  Files          376      376              
  Lines        39371    39371              
===========================================
+ Hits         25273    25275       +2     
+ Misses       14098    14096       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@varjolintu varjolintu left a comment

Choose a reason for hiding this comment

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

Does not work as expected. When using --quiet the prompt now shows the "Enter password to unlock" text because that is also written to STDERR. Only the errors should be written to STDERR when in quiet mode.

@droidmonkey
Copy link
Member Author

droidmonkey commented Aug 20, 2025

It is writing the unlock prompt to stderr right now by default 😅. When in quiet mode is just doesn't write the prompt at all, which doesn't make sense.

The point of quiet mode is that nothing but data is written to stdout

@varjolintu
Copy link
Member

varjolintu commented Aug 20, 2025

It is writing the unlock prompt to stderr right now by default 😅. When in quiet mode is just doesn't write the prompt at all, which doesn't make sense.

The point of quiet mode is that nothing but data is written to stdout

That was a bit unclear for me, because I thought only the errors should be written in quiet mode, not the password prompt.
So if you are absolutely certain about this, go ahead.

@droidmonkey droidmonkey requested a review from phoerious August 20, 2025 10:57
@droidmonkey
Copy link
Member Author

I'd like to get @phoerious opinion, too.

@phoerious
Copy link
Member

phoerious commented Aug 20, 2025

IMHO, stdout should always be for anything that is payload data that you'd want to pipe somewhere or write to a file and stderr for anything that isn't, such as error and status messages. The prompt should be stderr as well. --quiet should suppress everything.

@droidmonkey
Copy link
Member Author

droidmonkey commented Aug 20, 2025

The prompt should be stderr as well. --quiet should suppress everything

Even errors?

@phoerious
Copy link
Member

Errors should be communicated via return codes. What we could also do is -q for no output and -qq for no error output.

@droidmonkey
Copy link
Member Author

That is a decent idea, I'll see what I can do here.

@droidmonkey droidmonkey modified the milestones: v2.7.11, v2.8.0 Aug 24, 2025
@droidmonkey droidmonkey marked this pull request as draft August 24, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

keepassxc-cli show --quiet silently fails when providing a non-existent DB or invalid credentials
3 participants