Open
Conversation
Signed-off-by: walteck <walteck@users.noreply.github.com>
terado
reviewed
Jan 22, 2026
Comment on lines
+27
to
+31
| required_fields = ['action', 'issue', 'repository'] | ||
| missing = [field for field in required_fields if field not in payload] | ||
|
|
||
| if missing: | ||
| return False, f"Missing required fields: {', '.join(missing)}" |
There was a problem hiding this comment.
This code repeats 3 times, feels like it could be a function e.g
if check_missing(payload, ['action', 'issue', 'repository']);
terado
reviewed
Jan 22, 2026
Comment on lines
+38
to
+39
| if issue_missing: | ||
| return False, f"Missing required issue fields: {', '.join(issue_missing)}" |
There was a problem hiding this comment.
In fact, more than 3 times between the functions, could be used here, e.g
if check_missing(issue, ['number', 'user', 'title'])
return False, f"Missing required issue fields: {', '.join(issue_missing)}"
terado
reviewed
Jan 22, 2026
Comment on lines
+67
to
70
| response = self.requests.get( | ||
| f"https://api.github.com/orgs/{organization}/members?role=admin", | ||
| headers=self.auth_headers | ||
| ) |
There was a problem hiding this comment.
I'm posting naively here, not knowing this repo as well as yourself. Going purely on the description that this elevates permission - it feels like this file has a lot of URL injection opportunities. Is there anywhere in the chain that the correct organization, repository, issue_number etc are correct for the user requesting and are sanitised/viable content?
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.
Description
Added retry_with_backoff decorator in shared_functions.py with exponential backoff
Applied to all GitHub API calls (post_comment_on_issue, make_owner_on_github, close_issue, get_all_org_owners, make_member_on_github)
Server errors (5xx) trigger retries; client errors (4xx) raise GitHubAPIError
Configurable: max_retries, base_delay, max_delay, exponential_base
Added validation functions in utilities.py:
validate_issue_payload() - validates issue webhook payloads
validate_issue_comment_payload() - validates comment webhook payloads
validate_demotion_event() - validates Step Function events
Early return with error logging for invalid payloads
Added get_logger() for module-level loggers
Added log_audit_event() for structured audit logging with:
Event types: ELEVATION_REQUEST, ELEVATION_APPROVED, ELEVATION_GRANTED, ELEVATION_DENIED, DEMOTION_STARTED, DEMOTION_COMPLETED, etc.
Structured data: user, organization, repository, issue_number, approver, status, timestamp
Replaced print() statements with proper logger.info/warning/error
Added _try_claim_elevation_request() using DynamoDB conditional update
Uses ConditionExpression to atomically check status = 'pending' before promotion
Added _rollback_elevation_claim() for failure recovery
Status flow: pending → processing → elevated → demoted
Multiple approvals on same request are safely rejected
Context
Exploring failure modes and improving their handling
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.