Initialize ET and RoG connections only when needed#319
Merged
kkaarreell merged 1 commit intomainfrom Feb 13, 2026
Merged
Conversation
Avoid unnecessary external service connections by checking event types before initializing Errata Tool and RoG connections in execute and report commands. This prevents connection errors when processing non-erratum or non-RoG events. Changes: - execute_cmd.py: Check for ERRATUM/ROG events before connecting - report_cmd.py: Check for ERRATUM/ROG events before connecting - Follows the same defensive pattern already used in jira_cmd.py Fixes traceback when running execute -C on jobs without erratum events. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Reviewer's GuideDefensively gate Errata Tool and RoG connections in execute and report commands so they are only initialized when corresponding ERRATUM/ROG events are present, preventing unnecessary external calls and tracebacks for jobs without those event types. Sequence diagram for conditional ET/RoG initialization in execute commandsequenceDiagram
actor User
participant CLI
participant ExecuteCommand as cmd_execute
participant ReportPortal as ReportPortal
participant ErrataTool as ErrataTool
participant RoGTool as RoGTool
User->>CLI: run execute
CLI->>ExecuteCommand: cmd_execute(ctx, schedule_job_list)
ExecuteCommand->>ReportPortal: initialize_rp_connection(ctx)
Note over ExecuteCommand: rp initialized unconditionally
alt et_enable_comments is true
ExecuteCommand->>ExecuteCommand: has_erratum = any(job.event.type_ == EventType.ERRATUM for job in schedule_job_list)
alt has_erratum is true
ExecuteCommand->>ErrataTool: initialize_et_connection(ctx)
ErrataTool-->>ExecuteCommand: et connection
else has_erratum is false
Note over ExecuteCommand: et remains None (no ErrataTool connection)
end
else et_enable_comments is false
Note over ExecuteCommand: et remains None (comments disabled)
end
alt rog_enable_comments is true and rog_token present
ExecuteCommand->>ExecuteCommand: has_rog = any(job.event.type_ == EventType.ROG for job in schedule_job_list)
alt has_rog is true
ExecuteCommand->>RoGTool: RoGTool(token=ctx.settings.rog_token)
RoGTool-->>ExecuteCommand: rog client
else has_rog is false
Note over ExecuteCommand: rog remains None (no RoGTool connection)
end
else rog_enable_comments is false or rog_token missing
Note over ExecuteCommand: rog remains None
end
ExecuteCommand-->>CLI: proceed to execute jobs using rp, et, rog
Sequence diagram for conditional ET/RoG initialization in report commandsequenceDiagram
actor User
participant CLI
participant ReportCommand as cmd_report
participant ReportPortal as ReportPortal
participant Jira as Jira
participant ErrataTool as ErrataTool
participant RoGTool as RoGTool
User->>CLI: run report
CLI->>ReportCommand: cmd_report(ctx)
alt rp_url is configured
ReportCommand->>ReportPortal: initialize_rp_connection(ctx)
ReportPortal-->>ReportCommand: rp connection
else rp_url not configured
Note over ReportCommand: rp is None
end
ReportCommand->>Jira: ctx.get_jira_connection().get_connection()
Jira-->>ReportCommand: jira_connection
alt et_enable_comments is true
ReportCommand->>ReportCommand: has_erratum = any(job.event.type_ == EventType.ERRATUM for job in all_execute_jobs)
alt has_erratum is true
ReportCommand->>ErrataTool: initialize_et_connection(ctx)
ErrataTool-->>ReportCommand: et connection
else has_erratum is false
Note over ReportCommand: et remains None (no ErrataTool connection)
end
else et_enable_comments is false
Note over ReportCommand: et remains None
end
alt rog_enable_comments is true and rog_token present
ReportCommand->>ReportCommand: has_rog = any(job.event.type_ == EventType.ROG for job in all_execute_jobs)
alt has_rog is true
ReportCommand->>RoGTool: RoGTool(token=ctx.settings.rog_token)
RoGTool-->>ReportCommand: rog client
else has_rog is false
Note over ReportCommand: rog remains None
end
else rog_enable_comments is false or rog_token missing
Note over ReportCommand: rog remains None
end
ReportCommand-->>CLI: generate reports using rp, jira_connection, et, rog
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 left some high level feedback:
- The new Errata Tool and RoG initialization logic in both execute_cmd.py and report_cmd.py is nearly identical; consider extracting a shared helper (e.g.,
get_optional_et(ctx, jobs)/get_optional_rog(ctx, jobs)) to avoid duplication and keep future changes in sync. - Since you now compute
has_erratumandhas_rogby scanning all jobs, it might be worth consolidating the twoany(...)passes into a single loop over the job list (tracking both flags) if these job lists can be large or this path is performance-sensitive.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new Errata Tool and RoG initialization logic in both execute_cmd.py and report_cmd.py is nearly identical; consider extracting a shared helper (e.g., `get_optional_et(ctx, jobs)` / `get_optional_rog(ctx, jobs)`) to avoid duplication and keep future changes in sync.
- Since you now compute `has_erratum` and `has_rog` by scanning all jobs, it might be worth consolidating the two `any(...)` passes into a single loop over the job list (tracking both flags) if these job lists can be large or this path is performance-sensitive.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Avoid unnecessary external service connections by checking event types before initializing Errata Tool and RoG connections in execute and report commands. This prevents connection errors when processing non-erratum or non-RoG events.
Changes:
Fixes traceback when running execute -C on jobs without erratum events.
🤖 Generated with Claude Code
Summary by Sourcery
Bug Fixes: