Skip to content

fix: yield proper error message in case a local git source file is not retrievable#3892

Merged
johanneskoester merged 2 commits intomainfrom
fix/error_local_git_source_file
Dec 19, 2025
Merged

fix: yield proper error message in case a local git source file is not retrievable#3892
johanneskoester merged 2 commits intomainfrom
fix/error_local_git_source_file

Conversation

@johanneskoester
Copy link
Copy Markdown
Contributor

@johanneskoester johanneskoester commented Dec 19, 2025

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages when loading workflow files from Git — messages now indicate a consistent, user-facing path and suggest that a local clone may be outdated when relevant.
    • Clarified failure reporting for non-Git file access to provide better traceability.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 19, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Introduce log_path for consistent error reporting and wrap the local Git git.show call in a try/except to raise a WorkflowError with a message (including log_path) when the Git command fails; update non-Git failure messages to use log_path.

Changes

Cohort / File(s) Summary
Error handling & error-message normalization
src/snakemake/sourcecache.py
Add log_path derived from source_file; wrap LocalGitFile git.Repo(...).git.show(...) in try/except to catch GitCommandError and raise WorkflowError with log_path and an update-suggestion; update non-Git failure path to report log_path in error messages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Check try/except correctly narrows scope and only catches intended GitCommandError.
  • Verify log_path calculation is correct for varied source_file inputs.
  • Confirm error messages include log_path and do not leak sensitive paths.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: improving error messaging when a local git source file cannot be retrieved.
Description check ✅ Passed The PR description follows the repository template with both QC checklist items completed, though it lacks a detailed description of the changes above the checklist.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60cbbfa and 24c3550.

📒 Files selected for processing (1)
  • src/snakemake/sourcecache.py (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link
Copy Markdown
Contributor

Please format your code with pixi run format

Copy link
Copy Markdown
Contributor

@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: 0

🧹 Nitpick comments (1)
src/snakemake/sourcecache.py (1)

454-464: Excellent error handling improvement! Consider adding exception chaining.

The try/except wrapper and helpful error message with actionable suggestion significantly improve the user experience.

Consider using raise ... from e to preserve the exception chain for better debugging:

🔎 Suggested improvement for exception chaining
             except git.GitCommandError as e:
-               raise WorkflowError(
+               raise WorkflowError(
                    f"Failed to get local git source file {log_path}: {e}. "
                    "Is the local git clone up to date?"
-               )
+               ) from e

This follows Python best practices for exception handling and helps developers trace the root cause when debugging.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 005c92d and 60cbbfa.

📒 Files selected for processing (1)
  • src/snakemake/sourcecache.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • src/snakemake/sourcecache.py
🪛 Ruff (0.14.8)
src/snakemake/sourcecache.py

461-464: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


461-464: Avoid specifying long messages outside the exception class

(TRY003)


470-470: Do not catch blind exception: Exception

(BLE001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (45)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (5, macos-latest, py313)
  • GitHub Check: tests (6, macos-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (7, macos-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: tests (4, macos-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (1, ubuntu-latest, py313)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (2, macos-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py311)
🔇 Additional comments (2)
src/snakemake/sourcecache.py (2)

449-450: LGTM! Good refactoring for consistent error messages.

Introducing log_path improves error message consistency and ensures secrets are not leaked in logs.


472-472: LGTM! Consistent error message improvement.

Using log_path here ensures consistent, secret-free error messages across all failure paths.

@johanneskoester johanneskoester merged commit ed79cae into main Dec 19, 2025
55 of 57 checks passed
@johanneskoester johanneskoester deleted the fix/error_local_git_source_file branch December 19, 2025 18:39
johanneskoester pushed a commit that referenced this pull request Jan 8, 2026
🤖 I have created a release *beep* *boop*
---


##
[9.14.6](v9.14.5...v9.14.6)
(2026-01-08)


### Bug Fixes

* create local clone of git repos for source files from hosting
providers ([#3643](#3643))
([d2f8aba](d2f8aba))
* create potentially missing .snakemake folder in case of very long
command lines for spawned jobs
([#3894](#3894))
([4b431dd](4b431dd))
* make ilp solver enumeration lazy
([#3900](#3900))
([30e1509](30e1509))
* Prevent broken report_href links by using deterministic report IDs
with fixed prefix length
([#3889](#3889))
([6d8f4d8](6d8f4d8))
* refactor LoggerManager setup and scope
([#3851](#3851))
([f46d904](f46d904))
* yield proper error message in case a local git source file is not
retrievable
([#3892](#3892))
([ed79cae](ed79cae))


### Documentation

* explain how to pass nested config via CLI
([#3885](#3885))
([9d8c539](9d8c539))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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