Skip to content

ref(vcs): Improve find_base_sha debuggability#2806

Merged
szokeasaurusrex merged 1 commit intomasterfrom
szokeasaurusrex/improve-find_base_sha
Sep 29, 2025
Merged

ref(vcs): Improve find_base_sha debuggability#2806
szokeasaurusrex merged 1 commit intomasterfrom
szokeasaurusrex/improve-find_base_sha

Conversation

@szokeasaurusrex
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex commented Sep 29, 2025

Rather than emitting debug! logs (which we don't show in tests) within the find_base_sha and extract_pr_base_sha_from_event function, improve these methods by returning proper error types, which include the underlying error as a cause.

The calling code is now responsible for debug-logging these errors, which is still desired, as we expect these functions to error when run outside of a GitHub Actions environment. But, now we will have more information available when debugging test failures, and the debug logs at runtime will also likely be more detailed.


Note

Refactors base SHA discovery to return Result<Option> with contextual errors and updates caller to debug-log failures.

  • VCS utils (src/utils/vcs.rs):
    • Change find_base_sha to Result<Option<String>>; add contextual errors when reading/parsing GITHUB_EVENT_PATH.
    • Make extract_pr_base_sha_from_event return Result<Option<String>> with JSON parse context.
    • Import Context and propagate errors instead of silent debug logs.
    • Update tests to expect Option on success paths and errors on malformed JSON/missing env.
  • Build upload (src/commands/build/upload.rs):
    • Update base SHA resolution to handle Result<Option<...>>; add inspect_err debug logging and flatten Option.

Written by Cursor Bugbot for commit 1c17276. This will update automatically on new commits. Configure here.

Rather than emitting `debug!` logs (which we don't show in tests) within the `find_base_sha` and `extract_pr_base_sha_from_event` function, improve these methods by returning proper error types, which include the underlying error as a cause.

The calling code is now responsible for debug-logging these errors, which is still desired, as we expect these functions to error when run outside of a GitHub Actions environment. But, now we will have more information available when debugging test failures, and the debug logs at runtime will also likely be more detailed.
.or_else(|| vcs::find_base_sha().ok().map(Cow::Owned));
.or_else(|| {
vcs::find_base_sha()
.inspect_err(|e| debug!("Error finding base SHA: {}", e))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TIL inspect_err. nice!

Copy link
Copy Markdown
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

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

LGTM

@szokeasaurusrex szokeasaurusrex merged commit 5e5933f into master Sep 29, 2025
25 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/improve-find_base_sha branch September 29, 2025 10:38
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