From 831bd5cb0f69efb2884ff0c4aaa9306661e7d06e Mon Sep 17 00:00:00 2001 From: Shrikanth Upadhayaya <shrik450@gmail.com> Date: Mon, 17 Mar 2025 15:20:47 -0400 Subject: [PATCH] Raise a clearer error if design review number is not set If `post-dr-comment` is called in a run which is not on a design review, the DR number is not set in the context. This previously led to an incomprehensible error. This commit checks early to make sure the design review number is set and errors with an explanation if it isn't. --- post_dr_comment.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/post_dr_comment.py b/post_dr_comment.py index 58acabc..0bdc55a 100755 --- a/post_dr_comment.py +++ b/post_dr_comment.py @@ -168,6 +168,11 @@ def main(): args = parser.parse_args() + if not args.design_review_number.isdigit(): + raise ValueError( + "Design review number is either not set or not a number; this run may not be on a pull request event?" + ) + logger.setLevel(args.log_level.upper()) client = AllSpice( args.allspice_hub_url,