Skip to content

Fix return value for sync verification#204

Merged
ColdHeat merged 2 commits intoCTFd:masterfrom
sdalv1k:patch-1
Apr 9, 2026
Merged

Fix return value for sync verification#204
ColdHeat merged 2 commits intoCTFd:masterfrom
sdalv1k:patch-1

Conversation

@sdalv1k
Copy link
Copy Markdown
Contributor

@sdalv1k sdalv1k commented Apr 8, 2026

The other operations return 0 on success. Verify returned 1 on both failure and success.

Copy link
Copy Markdown
Contributor

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 adjusts the CLI challenge verify exit code behavior to align with other operations (returning 0 on success) and fix an inconsistent return value in sync verification.

Changes:

  • Update ChallengeCommand.verify() to return 0 in the non-exception path (previously returned 1).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ctfcli/cli/challenges.py Outdated
Comment on lines +1050 to +1053
if len(challenges_out_of_sync) > 1:
return 2

return 1
return 0
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

With this change, verify() will return 0 even when exactly one challenge is out of sync (because the only non-zero return is guarded by len(challenges_out_of_sync) > 1). That makes an out-of-sync verification indistinguishable from a fully-in-sync run for the common single-challenge case.

Consider returning 0 only when len(challenges_out_of_sync) == 0 and using the non-zero status (e.g., 2) for any out-of-sync count (> 0), while keeping 1 for exceptions/failures.

Copilot uses AI. Check for mistakes.
@ColdHeat
Copy link
Copy Markdown
Member

ColdHeat commented Apr 9, 2026

Your original code is right but I suspect the failed verifications code wouldn't always hit if the failed verification amount was only 1.

@ColdHeat ColdHeat merged commit 4d47e5e into CTFd:master Apr 9, 2026
6 checks passed
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.

3 participants