Skip to content

Fix update-checkout error reporting #60234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

etcwilde
Copy link
Member

In the event of a failure, update-checkout wouldn't always fail very
gracefully. As a result the actual failure wasn't always printed, which
makes it really difficult to figure out what's going on.

In my case, I'm jumping between 5.6 and main branches, so
the swift-cmark-gfm is causing update-checkout to hiccup since it's
not in the main configuration file scheme for main, but is in the
5.6 repository. You wouldn't know that though, since it would complain
about repo_path not being in the error message before crashing.

I've gone ahead and done some cleanups, reporting what the problem is at
the point of failure beyond the "key error 'swift-cmark-cfg'.

@etcwilde etcwilde requested review from lorentey and shahmishal July 25, 2022 23:28
@etcwilde
Copy link
Member Author

@swift-ci please test

@etcwilde
Copy link
Member Author

Pretty sure this one isn't me:

/Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/Basic/Utils.swift:31:27: error: value of type 'llvm.StringRef' has no member '__bytes_beginUnsafe'
      start: lhs._bridged.__bytes_beginUnsafe(),
             ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~
/Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/swift/SwiftCompilerSources/Sources/Basic/Utils.swift:32:66: error: value of type 'llvm.StringRef' has no member '__bytes_beginUnsafe'
      count: Int(lhs._bridged.__bytes_endUnsafe() - lhs._bridged.__bytes_beginUnsafe()))
                                                    ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~

@etcwilde
Copy link
Member Author

@swift-ci please test macOS platform

@shahmishal
Copy link
Member

@swift-ci python lint

In the event of a failure, update-checkout wouldn't always fail very
gracefully. As a result the actual failure wasn't always printed, which
makes it really difficult to figure out what's going on.

In my case, I'm jumping between 5.6 and main branches, so
the `swift-cmark-gfm` is causing update-checkout to hiccup since it's
not in the `main` configuration file scheme for `main`, but is in the
5.6 repository. You wouldn't know that though, since it would complain
about `repo_path` not being in the error message before crashing.

I've gone ahead and done some cleanups, reporting what the problem is at
the point of failure beyond the "key error 'swift-cmark-cfg'. Modernized
the error reporter a bit, so it should be a smidge easier to read.
@etcwilde etcwilde force-pushed the ewilde/fix-update-checkout-error-reporting branch from f2c927b to 73d2ac1 Compare July 26, 2022 16:28
@etcwilde
Copy link
Member Author

@swift-ci please smoke test

@etcwilde
Copy link
Member Author

@swift-ci please python lint

@etcwilde
Copy link
Member Author

etcwilde commented Aug 5, 2022

@swift-ci please smoke test

@etcwilde
Copy link
Member Author

etcwilde commented Aug 5, 2022

@swift-ci python lint

@etcwilde etcwilde requested a review from porglezomp August 5, 2022 06:28
Removing the `exit(1)` after failing. This shouldn't have an impact
since we've already failed and shouldn't have hit that. I may have kept
it from earlier debugging.

Replace `raise e` with just `raise`. It removes one level from the stack
trace where the actual `raise` takes place. The place we're actually
interested in is where the failure actually takes place.
@etcwilde etcwilde force-pushed the ewilde/fix-update-checkout-error-reporting branch from 8d80da8 to 71b3ff5 Compare August 5, 2022 06:29
@etcwilde
Copy link
Member Author

etcwilde commented Aug 5, 2022

@swift-ci please smoke test

@etcwilde
Copy link
Member Author

etcwilde commented Aug 5, 2022

@swift-ci please python lint

Comment on lines +74 to +78
try:
raise r
except KeyError as e:
messages.append(f"Failed to look up {e} in scheme\n")
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

I just realized you can make this a bit simpler and avoid the "raise for pattern matching" which is a bit quirky

Suggested change
try:
raise r
except KeyError as e:
messages.append(f"Failed to look up {e} in scheme\n")
except Exception:
if isinstance(r, KeyError):
messages.append(f"Failed to look up {r} in scheme\n")
else:

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure which read better. It should probably be single JobError with a __str__ method that just prints the right thing so this can just iterate over the list and print it without having to figure out what happened in the job that failed (even the KeyError here could lead to a misleading error message), but that is a bigger PR.

@AnthonyLatsis AnthonyLatsis added the update-checkout Area → utils: the `update-checkout` script label Sep 28, 2022
@etcwilde
Copy link
Member Author

@swift-ci please test

@hnrklssn
Copy link
Contributor

hnrklssn commented Mar 6, 2025

@etcwilde does the issue this fixes still exist?

@etcwilde
Copy link
Member Author

etcwilde commented Mar 6, 2025

I believe the failure output is still not great. I should fix this back up and get it merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
update-checkout Area → utils: the `update-checkout` script
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants