Skip to content

fix(cli): report failures of delete-file and dispatch-workflow - #961

Merged
heurtematte merged 2 commits into
mainfrom
fix/delete-file-dispatch-workflow-failures
Nov 19, 2026
Merged

heurtematte merged 2 commits into
mainfrom
fix/delete-file-dispatch-workflow-failures

Conversation

@heurtematte

Copy link
Copy Markdown
Contributor

Description

otterdog delete-file and otterdog dispatch-workflow now report their failures as errors and exit with 1. delete-file also warns when it skips an organization.

delete-file

Case Before After
File deleted "succeeded", exit 0 unchanged
File absent (GET 404) "succeeded" in red, exit 0 "not found, nothing to delete", exit 0
Reading the file fails (403, 5xx...) taken for an absent file, exit 0 error, exit 1, no DELETE sent
The path is a directory taken for an absent file, exit 0 error "is not a file", exit 1
The DELETE fails UnboundLocalError, exit 2, the remaining organizations are skipped "failed" and the error, exit 1, the remaining organizations still run
Repository missing from the configuration of the organization no output, exit 0 warning "not found in the configuration, skipped", exit 0
Repository archived in the configuration no output, exit 0 warning "is archived, skipped", exit 0

Why a skipped repository is a warning, not an error

  • Without organization arguments, delete-file runs over every organization of otterdog.json, and most of them do not have the repository given with --repo.
  • As an error, these organizations would make nearly every such run exit with 1, even when the file was deleted wherever the repository exists.
  • So the exit code stays 0, as on main, and the warning only makes the skip visible: before, these organizations printed nothing below their header.
  • Archived repositories are treated the same way, since no file can be deleted in them.
  • sync-template also skips these repositories, without a warning.
  • A typo in --repo therefore still ends with exit 0, but every organization now prints the warning.

dispatch-workflow

  • When GitHub answers anything other than 204, the error is printed with GitHub's status and body, and the command exits with 1. Before, it printed a plain line and exited with 0.
  • When reading the default branch fails, the command exits with 1 and the remaining organizations still run. Before, it exited with 2 and skipped them.

Both commands

  • --path and --workflow are now required. Without them, the commands requested contents/None or workflows/None/dispatches.
  • Values given by the user are escaped before rich prints them.

Related issue

Relates to #959 (follow-ups listed in its notes).

Type of change

  • 🐛 Bug fix (non-breaking change fixing an issue)
  • ✨ New feature (non-breaking change adding functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior, config schema, or default template)
  • 📝 Documentation only
  • 🔧 Refactoring / internal change (no functional change)

Breaking change details

The exit codes of the two commands change for failures that were reported as successes, or that crashed. Scripts may rely on them:

  • delete-file:
    • exit 1 instead of 0 when the file cannot be read, or when the path is not a file;
    • exit 1 instead of 2 when the deletion fails.
  • dispatch-workflow:
    • exit 1 instead of 0 when the dispatch fails;
    • exit 1 instead of 2 when reading the default branch fails.
  • --path (delete-file) and --workflow (dispatch-workflow) are required: Click exits with 2 when one is missing. No call that worked omitted them.

A repository missing from the configuration, or archived, keeps exit code 0.

Who is affected: CLI users and scripts that run these commands. Configurations and the webapp are not affected.

Tests

  • Unit tests added / updated under tests/

Checks run on 7fb0321:

Manual testing

  • GitHub API calls only stubbed / mocked in unit tests (no live testing)
  • Tested on a real GitHub organization (live GitHub API)

How to reproduce / test scenario:**

  1. Run pytest tests/operations/test_delete_file.py tests/operations/test_dispatch_workflow.py.
  2. On main, the failed deletion ends with UnboundLocalError, and a failed dispatch exits with 0.

Checklist

  • Documentation updated: not applicable. docs/reference/operations/index.md only lists the help lines, which are unchanged, and no page describes the options or exit codes of these commands.
  • Default template / examples updated if the config schema changed: not applicable, the schema and the defaults are unchanged.

delete-file failed with an UnboundLocalError when the deletion failed,
printed "succeeded" for a file that was not deleted, and took any failed
read of the file for an absent file. dispatch-workflow printed a failed
dispatch as a plain line and exited with 0.

Both commands now report these failures as errors, with the response of
GitHub, and exit with 1. An absent file is reported as such and keeps
exit code 0. As delete-file runs over all organizations by default, an
organization whose configuration lacks the repository, or archives it,
is skipped with a warning instead of no output, and keeps exit code 0.
--path and --workflow are now required.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: sebastien.heurtematte <sebastien.heurtematte@eclipse-foundation.org>
Only the call expected to raise SystemExit stays inside the block.
Reported by SonarQube Cloud (python:S5778).

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: sebastien.heurtematte <sebastien.heurtematte@eclipse-foundation.org>
@sonarqubecloud

Copy link
Copy Markdown

@heurtematte
heurtematte requested a review from netomi November 19, 2026 12:38
@heurtematte
heurtematte merged commit 97bce29 into main Nov 19, 2026
12 checks passed
@heurtematte
heurtematte deleted the fix/delete-file-dispatch-workflow-failures branch November 19, 2026 13:24
@heurtematte
heurtematte temporarily deployed to pull-request-preview November 19, 2026 13:24 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
pull-request-preview — ff19b12f Deployed Nov 19, 2026 by heurtematte via remove the preview #50
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.

2 participants