sync.py: allow check_file to fail#2
Merged
aesteve-rh merged 1 commit intomainfrom Jan 21, 2026
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's Guidecheck_file now parses the git command output into a SyncStatus and can surface non-success statuses instead of always reporting success. Sequence diagram for updated check_file status handlingsequenceDiagram
participant Caller
participant SyncService
participant GitBackend
participant SyncStatus
participant SyncResult
Caller->>SyncService: check_file(remote_name, file_sync)
SyncService->>GitBackend: run_git_check(remote_name, file_sync)
GitBackend-->>SyncService: git_result(message, objects_processed)
SyncService->>SyncStatus: from_text(git_result.message)
alt message maps to known status
SyncStatus-->>SyncService: status
else message does not map (ValueError)
SyncStatus--xSyncService: ValueError
SyncService->>SyncService: status = SyncStatus.SUCCESS
end
SyncService->>SyncResult: create(file_sync, remote_name, status, git_result.message, git_result.objects_processed, local_hash=None)
SyncService-->>Caller: SyncResult
Class diagram for SyncStatus and SyncResult usage in check_fileclassDiagram
class SyncService {
+check_file(remote_name: str, file_sync: FileSync) SyncResult
}
class FileSync {
+include: str
+exclude: str
}
class SyncStatus {
<<enumeration>>
SUCCESS
FAILURE
WARNING
+from_text(message: str) SyncStatus
}
class SyncResult {
+file_sync: FileSync
+remote_name: str
+status: SyncStatus
+message: str
+files_processed: int
+local_hash: str
}
SyncService --> FileSync : uses
SyncService --> SyncResult : returns
SyncService --> SyncStatus : parses
SyncResult --> FileSync : contains
SyncResult --> SyncStatus : has_status
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Catching a broad ValueError and defaulting to SUCCESS risks silently masking unexpected parsing issues; consider logging the exception or at least the unparseable message to make those cases visible during debugging.
- If SyncStatus.from_text can fail for known non-success states (e.g., malformed but clearly indicating failure), you might want to distinguish between an unknown status (default to SUCCESS) and a clearly non-success indication to avoid treating genuine failures as successes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Catching a broad ValueError and defaulting to SUCCESS risks silently masking unexpected parsing issues; consider logging the exception or at least the unparseable message to make those cases visible during debugging.
- If SyncStatus.from_text can fail for known non-success states (e.g., malformed but clearly indicating failure), you might want to distinguish between an unknown status (default to SUCCESS) and a clearly non-success indication to avoid treating genuine failures as successes.
## Individual Comments
### Comment 1
<location> `src/git_crossref/sync.py:121` </location>
<code_context>
+ try:
+ status = SyncStatus.from_text(git_result.message)
+ except ValueError:
+ status = SyncStatus.SUCCESS
+
return SyncResult(
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Defaulting to SUCCESS on parse failure may mask unexpected or malformed status messages.
If `SyncStatus.from_text` raises `ValueError`, defaulting to `SUCCESS` can hide real failures or new status types. Prefer a neutral/explicit fallback (e.g., `UNKNOWN` or `ERROR`), or propagate the parsing failure so unexpected formats don’t get reported as successful.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Signed-off-by: Albert Esteve <aesteve@redhat.com>
1c28135 to
7d9fe22
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Bug Fixes: