Skip to content

Fix silent submodule failure.#6

Open
whisper67265 wants to merge 4 commits intocppalliance:masterfrom
whisper67265:fix/silent-failure
Open

Fix silent submodule failure.#6
whisper67265 wants to merge 4 commits intocppalliance:masterfrom
whisper67265:fix/silent-failure

Conversation

@whisper67265
Copy link
Copy Markdown
Collaborator

@whisper67265 whisper67265 commented May 5, 2026

issue : #10

Summary by CodeRabbit

  • Bug Fixes

    • Workflows now detect and surface submodule, clone, fetch and missing-doc failures as fatal; any fatal submodule causes the run to abort after processing.
    • Added per-submodule fatal aggregation and explicit post-run summary output to show outcomes.
  • Chores

    • Commits are only made when there are staged changes.
    • Submodule init/update and fetch now return and surface errors instead of suppressing them; missing submodule paths emit warnings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

Per-submodule processing and error handling in GitHub Actions were hardened: commits are only made when staged changes exist; submodule init/fetch/clone/doc-path failures now surface (fatal rc=2) and are aggregated via a submodule_fatal counter causing workflow failure when any fatal occurs.

Changes

Submodule handling, guarded commits, and error propagation

Layer / File(s) Summary
Data / Signal shape
.github/workflows/add-submodules.yml, .github/workflows/start-translation.yml
Introduced per-submodule metadata buckets (UPDATES, META_MISSING, NO_DOC_PATHS, REPO_EXISTS_SKIP, ORG_REPO_MISSING) and a submodule_fatal counter; certain failures (doc_paths retrieval, missing libraries.json, missing org/repo, clone failures) now return exit code 2 to mark fatal submodule errors.
Core implementation
.github/workflows/assets/lib.sh
Guarded commits: only commit when staged changes exist (git diff --cached --quiet used). git submodule update --init and fetch calls now propagate errors instead of silencing them; fetch errors are no longer redirected to /dev/null.
Per-submodule control flow
.github/workflows/add-submodules.yml, .github/workflows/start-translation.yml
process_one_submodule updated to skip when repo already exists, treat missing module/org or missing libraries/doc paths as fatal (rc==2), propagate failures from repo creation/clone/sync steps (`
Wiring / integration
.github/workflows/sync-translation.yml
Submodule init/update sequence simplified: git submodule update --init runs without suppressed errors; explicit missing-subpath warning added; per-submodule fetch and git submodule update --remote run without prior suppression or silent skipping of failures.
Summary / Exit handling
.github/workflows/add-submodules.yml, .github/workflows/start-translation.yml
Added post-processing summary output; after iterating submodules the workflow exits non-zero if any submodule_fatal occurred.
Messaging / UX
workflow files and assets/lib.sh
Log messages for skipped commits, submodule init/update failures, clone failures, and final fatal-summary updated; no public API signature changes.

Sequence Diagram(s)

sequenceDiagram
  participant Runner as GitHub Runner
  participant Workflow as Workflow script
  participant Git as git CLI
  participant Remote as origin (remote repo)

  Note over Runner,Workflow: Workflow starts (start-translation / sync-translation / add-submodules)
  Runner->>Workflow: invoke workflow
  Workflow->>Git: git submodule update --init
  Git-->>Workflow: success / failure
  alt init failure
    Workflow->>Runner: print error & return rc 1
  else init success
    Workflow->>Git: for each submodule: check path exists
    alt path missing
      Workflow->>Runner: warn and skip
    else path present
      Workflow->>Git: git fetch origin (no suppression)
      Git-->>Workflow: fetch result
      Workflow->>Git: git submodule update --remote "$sub_path"
      Git-->>Workflow: update result (0 / 1 / 2)
      alt rc == 0
        Workflow->>Workflow: append submodule to UPDATES
      else rc == 2
        Workflow->>Workflow: increment submodule_fatal
      end
    end
  end
  Workflow->>Git: if staged changes -> git commit && git push
  Git-->>Workflow: commit result
  Workflow->>Runner: if submodule_fatal > 0 -> exit non-zero with summary
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • cppalliance/boost-docs-translation#3: Modifies per-submodule workflow logic and org selection; touches similar workflow areas (submodule handling) and may overlap in behavior changes.

Poem

I hop through branches, sniff each hidden root,
If clones fall flat, I cry "Exit two!" — hoot hoot.
Commits wait patient for staged leaves to show,
No quiet failures—errors now must go.
A rabbit guards the workflow, soft and spry. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Fix silent submodule failure' accurately captures the main objective of the changes, which involve adding error handling and fatal exit codes to prevent silent failures in submodule operations across multiple workflow files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/add-submodules.yml:
- Around line 176-187: The loop currently calls process_one_submodule and
immediately relies on rc but set -e causes the script to exit on non-zero
returns; change the call so the return code is captured without triggering
errexit (e.g., invoke process_one_submodule and on failure assign rc from $? ,
then default rc to 0 if unset) and then use rc to decide whether to append to
UPDATES or increment submodule_fatal; alternatively wrap the
process_one_submodule call in a subshell or temporarily disable errexit around
that call to preserve existing rc/submodule_fatal/UPDATES logic.

In @.github/workflows/start-translation.yml:
- Around line 324-335: The loop currently invokes process_one_submodule under
set -e which causes the script to exit before capturing its status; change the
invocation to capture the exit code without triggering errexit (e.g., run
process_one_submodule "$sub" with an explicit || rc=$? or an if ...; then/else
wrapper so the shell does not exit) and then use that rc to decide behavior: if
rc==0 append to UPDATES, if rc==2 increment submodule_fatal; also update
process_one_submodule to explicitly return distinct codes for fatal vs non-fatal
failures (use return 2 for fatal conditions) so the loop can properly count
submodule_fatal and avoid premature exits.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c172c863-6dc5-41d7-bf48-966564ec5013

📥 Commits

Reviewing files that changed from the base of the PR and between bdfb682 and a9f8d2e.

📒 Files selected for processing (4)
  • .github/workflows/add-submodules.yml
  • .github/workflows/assets/lib.sh
  • .github/workflows/start-translation.yml
  • .github/workflows/sync-translation.yml

Comment thread .github/workflows/add-submodules.yml Outdated
Comment thread .github/workflows/start-translation.yml Outdated
@whisper67265 whisper67265 requested a review from jonathanMLDev May 5, 2026 22:44
Comment thread .github/workflows/add-submodules.yml Outdated
Comment thread .github/workflows/start-translation.yml Outdated
Comment thread .github/workflows/sync-translation.yml Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/add-submodules.yml:
- Around line 171-185: process_one_submodule currently masks failures because
create_new_repo_and_push does not return non-zero on fatal errors; update
create_new_repo_and_push to check each step (create_repo, git commit, git push,
etc.) and explicitly return 2 on unrecoverable failures (matching the pattern
used around the other calls at the earlier checks in the script such as the
checks at lines similar to 112–114 and 118–119), or propagate errors by enabling
set -o errexit within the function scope and wrapping critical commands with
conditional checks that set rc=2 and return 2 on failure so
process_one_submodule’s caller won’t append failed submodules to UPDATES.

In @.github/workflows/start-translation.yml:
- Around line 319-333: The helpers are masking git failures because functions
like sync_repo_master, update_local_merge_from_master,
ensure_local_branch_in_repo, and process_local_branch run git commands without
checking exit codes and process_local_branch currently always returns success;
update these functions so every git command is followed by an explicit check
(e.g., command || return 2) or otherwise test $? and return a non-zero/fatal
status, ensure process_local_branch returns that propagated error instead of
unconditionally 0, and make process_one_submodule treat a returned 2 as fatal so
the aggregation loop can detect and fail fast.

In @.github/workflows/sync-translation.yml:
- Around line 65-72: The loop that checks each submodule path (reading into
sub_path after git submodule update --init) currently logs a warning and uses
continue when a submodule directory is missing; change this to mark failure and
cause the job to fail instead of silently succeeding: either set a failure flag
(e.g., missing_submodules or reuse updated) when [[ ! -d "$sub_path" ]] is true
and continue to gather all missing entries, then after the while loop check that
flag and exit with a non-zero status (exit 1) if any were missing, or
immediately exit 1 inside the if block; reference the variables/labels sub_path,
updated (or your chosen missing_submodules flag), and the existing warning echo
to locate where to change behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0fe123b9-f054-4193-8553-47d6fff6d945

📥 Commits

Reviewing files that changed from the base of the PR and between d079493 and d41a02f.

📒 Files selected for processing (3)
  • .github/workflows/add-submodules.yml
  • .github/workflows/start-translation.yml
  • .github/workflows/sync-translation.yml

Comment thread .github/workflows/add-submodules.yml
Comment thread .github/workflows/start-translation.yml
Comment thread .github/workflows/sync-translation.yml
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/add-submodules.yml (1)

135-135: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Missing error propagation from create_new_repo_and_push.

When process_one_submodule is called as the condition of if (line 185), set -e is disabled for the entire function body. If create_new_repo_and_push returns 2 here, the error is silently ignored and process_one_submodule returns 0, causing a failed submodule to be marked as successfully updated.

🐛 Proposed fix
-            create_new_repo_and_push "$MODULE_ORG" "$sub_name" "$sub_clone" "$org_repo_url" "$LIBS_REF"
+            create_new_repo_and_push "$MODULE_ORG" "$sub_name" "$sub_clone" "$org_repo_url" "$LIBS_REF" || return 2
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/add-submodules.yml at line 135, process_one_submodule
currently calls create_new_repo_and_push but ignores its exit status when used
in an if-context, so failures (e.g., return 2) get swallowed; update
process_one_submodule to propagate errors from create_new_repo_and_push by
checking its return code and returning a non-zero status on failure (e.g.,
capture its exit code after the call and if non-zero, return that code or fail
the function), ensuring create_new_repo_and_push's failure is not silently
treated as success.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In @.github/workflows/add-submodules.yml:
- Line 135: process_one_submodule currently calls create_new_repo_and_push but
ignores its exit status when used in an if-context, so failures (e.g., return 2)
get swallowed; update process_one_submodule to propagate errors from
create_new_repo_and_push by checking its return code and returning a non-zero
status on failure (e.g., capture its exit code after the call and if non-zero,
return that code or fail the function), ensuring create_new_repo_and_push's
failure is not silently treated as success.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fed114c7-6e99-4a74-9547-dcf818243407

📥 Commits

Reviewing files that changed from the base of the PR and between d41a02f and 5b0b8bb.

📒 Files selected for processing (2)
  • .github/workflows/add-submodules.yml
  • .github/workflows/start-translation.yml

@whisper67265 whisper67265 requested a review from jonathanMLDev May 6, 2026 21:39
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