Skip to content

fix: fixed upper bound on step number and moved private GitHub helper methods to utils package#2755

Merged
muddlebee merged 4 commits into
Tracer-Cloud:mainfrom
SaptarshiSarkar12:issue/2719-move-helpers-and-fix-step-log
Jun 5, 2026
Merged

fix: fixed upper bound on step number and moved private GitHub helper methods to utils package#2755
muddlebee merged 4 commits into
Tracer-Cloud:mainfrom
SaptarshiSarkar12:issue/2719-move-helpers-and-fix-step-log

Conversation

@SaptarshiSarkar12

Copy link
Copy Markdown
Contributor

Fixes #2719

Describe the changes you have made in this PR

In this pull request, I have addressed the following changes:

  • I have ensured the upper bound on the step_number is pre-calculated as the total count of grouped steps
  • I have moved GitHub MCP helper methods to app/tools/utils/github_helpers.py file and modified relevant tools and test files

Demo/Screenshot for feature changes and bug fixes

No demo attached as the issue is about refactoring existing code


Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:

The complete log content has ungrouped and grouped parts. The total sum of grouped parts is the maximum possible step_number value. So, I have used that value as its upper bound.

I have converted the private helper methods to public methods in app/tools/utils/github_helpers.py file. On performing those changes across all GitHub related tools, the tests failed due to mockup methods. So, I refactored those mock calls to github_helpers file and the tests pass! 🎉


Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

Note: Please check Allow edits from maintainers if you would like us to assist in the PR.

…number filters the log content correctly

Signed-off-by: Saptarshi Sarkar <saptarshi.programmer@gmail.com>
Signed-off-by: Saptarshi Sarkar <saptarshi.programmer@gmail.com>
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Greptile code review

This repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md.

Run a review — add a PR comment with:

@greptile review

Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5.

Optional: automate with the greploop skill.

…d_github_mcp_config` methods in git deploy timeline tool test

Signed-off-by: Saptarshi Sarkar <saptarshi.programmer@gmail.com>
@greptile-apps

greptile-apps Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes an off-by-one bug in extract_step_log where step_number was validated against len(sections) (which includes ungrouped pseudo-sections) instead of the count of actual named groups, and refactors the four private GitHub helper functions out of GitHubSearchCodeTool into a shared app/tools/utils/github_helpers.py module consumed by all six GitHub-related tools.

  • Bug fix (GitHubActionsTool/__init__.py): group_count is now pre-computed as the number of named (non-ungrouped) sections; the step_number range guard uses this value so step numbers between group_count + 1 and the old len(sections) no longer silently enter the selection loop with incorrect results.
  • Refactor (app/tools/utils/github_helpers.py + 5 tool files): _resolve_config, _normalize_tool_result, _gh_creds, and _gh_available are promoted to public, descriptively-named helpers in a dedicated utils module; all consumer tools and their test patches are updated accordingly.
  • Tests: Two new tests cover the step_number fix — a valid step_number=1 case and an out-of-bounds step_number=3 case against a 2-group log.

Confidence Score: 5/5

Safe to merge — the refactor is a mechanical rename with no logic changes, and the step_number bound fix is correct and well-tested.

The helper extraction is a straight copy-and-rename with all call sites and test patches updated consistently. The extract_step_log fix correctly narrows the upper bound from total section count to named-group count, and two new tests directly validate both the happy path and the previously-broken out-of-bounds case.

No files require special attention.

Important Files Changed

Filename Overview
app/tools/utils/github_helpers.py New shared module — exact copy of the private helpers previously in GitHubSearchCodeTool, now with public names and descriptive docstrings; logic is unchanged.
app/tools/GitHubActionsTool/init.py Core bug fix: upper bound for step_number now uses group_count (named sections only) instead of len(sections); imports migrated to github_helpers.
app/tools/GitHubSearchCodeTool/init.py Private helper definitions removed; public equivalents re-imported from github_helpers for local use; no behavioral change.
tests/tools/test_github_actions_tool.py Mock targets updated to resolve_github_mcp_config; two new tests cover the step_number bounds fix (valid and out-of-bounds cases).
tests/tools/test_git_deploy_timeline_tool.py All patch targets migrated from app.tools.GitHubSearchCodeTool to app.tools.utils.github_helpers; no functional test changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Tools
        A[GitHubActionsTool]
        B[GitHubSearchCodeTool]
        C[GitHubCommitsTool]
        D[GitHubFileContentsTool]
        E[GitHubRepositoryTreeTool]
        F[GitDeployTimelineTool]
    end
    subgraph Utils
        G[github_helpers.py]
    end
    subgraph Integration
        H[github_mcp]
    end
    A --> G
    B --> G
    C --> G
    D --> G
    E --> G
    F --> G
    G --> H
Loading

Reviews (2): Last reviewed commit: "test: added test to check for invalid st..." | Re-trigger Greptile

Comment thread tests/tools/test_github_actions_tool.py
Signed-off-by: Saptarshi Sarkar <saptarshi.programmer@gmail.com>
@SaptarshiSarkar12

Copy link
Copy Markdown
Contributor Author

@greptile review

@SaptarshiSarkar12

Copy link
Copy Markdown
Contributor Author

@muddlebee I found out that the usage of private helper methods has been followed far and wide across the project. Should I refactor those methods in this PR or should I create a new issue + PR?

Some notable code examples across GitLab, BitBucket, Grafana, Sentry, Tracer, Lambda and EKS related tools:

and many more.

@muddlebee

Copy link
Copy Markdown
Collaborator

@SaptarshiSarkar12 we will need to fix those, we started revamping/refactoring our code, probably will take those later, but for now priority is functional for older integrations, and thanks for this. Looks good. LGTM

@muddlebee muddlebee merged commit c5df111 into Tracer-Cloud:main Jun 5, 2026
14 checks passed
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🐉 Legend says enough merged PRs and you ascend. @SaptarshiSarkar12 is dangerously close. 🌤️


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

@SaptarshiSarkar12

Copy link
Copy Markdown
Contributor Author

Okay thanks @muddlebee for merging this PR! ❤️

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.

chore: GitHub Actions tool optimizations

2 participants