Skip to content

feat(gitlab): add repository, code-review, and CI job tools + validation fixes#5205

Merged
waleedlatif1 merged 2 commits into
stagingfrom
gitlab-validate-tools
Jun 25, 2026
Merged

feat(gitlab): add repository, code-review, and CI job tools + validation fixes#5205
waleedlatif1 merged 2 commits into
stagingfrom
gitlab-validate-tools

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Validated the entire GitLab integration (tools, block, connector, triggers) against the live GitLab REST API v4 docs — connector and triggers came back clean (no changes needed)
  • Added 12 new tools, all host-aware (getGitLabApiBase) and wired end-to-end (types → index → registry → block):
    • Repository: list repository tree, get file, create file, update file, create branch, list branches, list commits
    • Code review: get MR changes (diffs), approve merge request
    • CI jobs: list pipeline jobs, get job log, play job
  • Validation fixes (existing surface):
    • Block: corrected inputs.credentialinputs.accessToken (matched the subBlock id and the params the block reads)
    • Tools: .trim() on projectId before URL-encoding in all existing tool request URLs (input hygiene)

Backwards compatibility

  • The only change to the original 19 tools is String(projectId)String(projectId).trim() (18 files; list_projects untouched). No-op when there's no surrounding whitespace; only prevents accidental-whitespace 404s. No endpoint/method/param/response/output of any existing tool changed.
  • types.ts removed only 4 dead, unused branch type stubs (repurposed for the new tools); registry.ts is a re-sort + additions (no existing entry dropped); block changes are additive plus the one input-key fix.

Type of Change

  • New feature (non-breaking)

Testing

  • Typecheck clean, biome clean, monorepo-boundary + realtime-prune + check:api-validation all pass, tools/gitlab/utils.test.ts 7/7
  • Each new tool independently verified (URL/method/body/transform) against the GitLab API docs; block↔tool alignment verified for all 12 new operations

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…ion fixes

Expand the GitLab integration with 12 new tools (all host-aware via
getGitLabApiBase, wired through types/index/registry/block):
- Repository: list_repository_tree, get_file, create_file, update_file,
  create_branch, list_branches, list_commits
- Code review: get_merge_request_changes, approve_merge_request
- CI jobs: list_pipeline_jobs, get_job_log, play_job

Validation fixes from /validate-integration:
- Correct the block inputs key (credential -> accessToken) so it matches the
  subBlock id and the params the block reads
- Trim projectId before encoding in all tool request URLs (input hygiene)

/validate-connector and /validate-trigger passed clean against the GitLab REST
API v4 docs — no changes required.
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 25, 2026 1:00am

Request Review

@cursor

cursor Bot commented Jun 25, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New write paths (file create/update, branch create, MR approve, play job) can mutate GitLab state; the accessToken input rename could break workflows that referenced credential.

Overview
Expands the GitLab integration with 12 new tools (repo tree/files/branches/commits, MR diffs and approvals, pipeline jobs/logs/manual play), wired through types, registry, the workflow block, and docs.

Repository & CI: New actions cover browsing the tree, reading/creating/updating files, listing commits and branches, creating branches, listing pipeline jobs, fetching job traces, and playing manual jobs.

Code review: gitlab_get_merge_request_changes calls the /diffs endpoint (replacing deprecated /changes); gitlab_approve_merge_request records MR approvals.

Fixes & docs: The GitLab block now exposes inputs.accessToken instead of inputs.credential. Existing tools trim projectId before URL encoding. Integration docs add optional host on actions plus a Triggers section; integrations.json bumps GitLab to 31 operations and 6 triggers (PagerDuty/Zendesk trigger metadata also updated).

Reviewed by Cursor Bugbot for commit 1e23b62. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR expands the GitLab integration with 12 new tools (repository tree, file CRUD, list branches/commits, MR diffs/approval, and CI job management), registers them in the block and global registry, and fixes the existing credentialaccessToken input key mismatch in the block.

  • 12 new tools — all host-aware, following the established pattern (encode projectId, read x-total from headers, consistent transformResponse error shape); get_merge_request_changes uses the replacement /diffs endpoint and get_file decodes base64 with Buffer consistent with other tools in the executor.
  • Block wiring — all new operations are added to the dropdown, conditional UI fields, and config.tool cases; the credentialaccessToken fix aligns the block's input key with the subBlock id and tool params.
  • Types & registryGitLabListBranchesParams/GitLabCreateBranchParams are now exported, all 10 new response types are added to the GitLabResponse union, and the registry is re-sorted alphabetically with no prior entries dropped.

Confidence Score: 5/5

Safe to merge — all 12 new tools follow established patterns, no existing tool behavior changed beyond the whitespace trim, and the credential key fix is correct.

All new tools are self-contained additions wired end-to-end with correct endpoints, method/body/header shapes, and type coverage. The only gaps are optional params (lastCommitId in update_file, date/author filters in list_commits) that the block config case omits — the tools themselves work correctly when called directly.

apps/sim/blocks/blocks/gitlab.ts — the config.tool cases for gitlab_update_file and gitlab_list_commits silently drop some optional tool params that may be useful in certain workflows.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/gitlab.ts Wires all 12 new tools into the block UI with correct conditions; fixes credential→accessToken input key; block config for update_file and list_commits omits some optional tool params.
apps/sim/tools/gitlab/types.ts Adds 10 new exported param/response interfaces and adds all 10 new response types to the GitLabResponse union; exports GitLabListBranchesParams and GitLabCreateBranchParams that were previously unexported.
apps/sim/tools/gitlab/get_merge_request_changes.ts New tool using the replacement /diffs endpoint with per_page=100; echoes mergeRequestIid from params since the response is a raw array.
apps/sim/tools/gitlab/update_file.ts New tool updating a repository file with optional lastCommitId for optimistic locking; correct PUT, properly conditionally sets last_commit_id in body.
apps/sim/tools/gitlab/list_commits.ts New tool listing commits with refName/since/until/path/author/pagination filters; all optional, reads x-total.
apps/sim/tools/gitlab/get_file.ts New tool reading a file and decoding base64 content with Buffer (Node executor only, consistent with other tools in the codebase).
apps/sim/tools/gitlab/index.ts Re-exports all 12 new tools; all imports present and consistent with new files.
apps/sim/tools/registry.ts Alphabetically re-sorts all gitlab entries and registers 12 new tools; no prior entries dropped.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Block["GitLab Block\n(gitlab.ts)"] -->|config.tool| Dispatcher["Operation Dispatcher\n(switch/case)"]

    Dispatcher --> RepoOps["Repository Ops"]
    Dispatcher --> MROps["Merge Request Ops"]
    Dispatcher --> CIOps["CI / Job Ops"]

    RepoOps --> T1["list_repository_tree"]
    RepoOps --> T2["get_file"]
    RepoOps --> T3["create_file"]
    RepoOps --> T4["update_file"]
    RepoOps --> T5["list_branches"]
    RepoOps --> T6["create_branch"]
    RepoOps --> T7["list_commits"]

    MROps --> T8["get_merge_request_changes\n(/diffs endpoint)"]
    MROps --> T9["approve_merge_request"]

    CIOps --> T10["list_pipeline_jobs"]
    CIOps --> T11["get_job_log"]
    CIOps --> T12["play_job"]

    T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9 & T10 & T11 & T12 --> Base["getGitLabApiBase(host)\n→ gitlab.com or self-managed"]
    Base --> API["GitLab REST API v4"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    Block["GitLab Block\n(gitlab.ts)"] -->|config.tool| Dispatcher["Operation Dispatcher\n(switch/case)"]

    Dispatcher --> RepoOps["Repository Ops"]
    Dispatcher --> MROps["Merge Request Ops"]
    Dispatcher --> CIOps["CI / Job Ops"]

    RepoOps --> T1["list_repository_tree"]
    RepoOps --> T2["get_file"]
    RepoOps --> T3["create_file"]
    RepoOps --> T4["update_file"]
    RepoOps --> T5["list_branches"]
    RepoOps --> T6["create_branch"]
    RepoOps --> T7["list_commits"]

    MROps --> T8["get_merge_request_changes\n(/diffs endpoint)"]
    MROps --> T9["approve_merge_request"]

    CIOps --> T10["list_pipeline_jobs"]
    CIOps --> T11["get_job_log"]
    CIOps --> T12["play_job"]

    T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9 & T10 & T11 & T12 --> Base["getGitLabApiBase(host)\n→ gitlab.com or self-managed"]
    Base --> API["GitLab REST API v4"]
Loading

Reviews (3): Last reviewed commit: "fix(gitlab): address review feedback + r..." | Re-trigger Greptile

Comment thread apps/sim/tools/gitlab/get_merge_request_changes.ts Outdated
Comment thread apps/sim/tools/gitlab/types.ts
Comment thread apps/sim/tools/gitlab/get_file.ts
Comment thread apps/sim/tools/gitlab/create_file.ts
@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends the GitLab integration with 12 new tools covering repository file operations (list tree, get/create/update file, list commits), branch management (list/create branches), code review (get MR diffs, approve MR), and CI jobs (list pipeline jobs, get job log, play job). It also fixes a long-standing bug where the block's credential input was keyed as credential instead of accessToken, which would have prevented the token from reaching any tool, and adds .trim() hygiene to projectId across all existing tools.

  • 12 new tools added end-to-end (types → tool file → index → registry → block), all host-aware via getGitLabApiBase and correctly wired to block inputs/outputs.
  • Credential key fix (inputs.credentialinputs.accessToken) corrects a bug that silently broke token delivery to every existing GitLab tool.
  • list_repository_tree block case omits a ref input and does not forward the tool's optional ref param, so tree listings via the block are always against the default branch.

Confidence Score: 4/5

The PR is safe to merge; the new tools are well-structured and the credential key fix unblocks the entire existing GitLab surface.

All 12 new tools follow existing patterns, are wired end-to-end, and have correct request/response shapes. The only gap is that the list_repository_tree block case doesn't expose or forward the ref param, locking users of that operation to the default branch when going through the block UI.

apps/sim/blocks/blocks/gitlab.ts — the list_repository_tree tool case and the block's ref input condition both need a small addition to support non-default branches.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/gitlab.ts Adds 12 new operations, fixes credential→accessToken key, new block inputs; list_repository_tree is missing a ref block input to target non-default branches
apps/sim/tools/gitlab/types.ts Adds new param/response interfaces for all 12 tools; all new types added to GitLabResponse union; existing branch types promoted to export
apps/sim/tools/registry.ts Re-sorted to alphabetical order and added all 12 new tools; no existing entries dropped
apps/sim/tools/gitlab/index.ts All 12 new tools imported and re-exported with correct grouping
apps/sim/tools/gitlab/get_file.ts New tool; correctly decodes base64 file content with Buffer.from on the server side; clean implementation
apps/sim/tools/gitlab/create_branch.ts New tool sending branch/ref as query params on POST; GitLab API v4 accepts this pattern, tool is otherwise well-formed
apps/sim/tools/gitlab/approve_merge_request.ts New tool; POSTs optional sha in body, correct response shape for approvals_required/approvals_left
apps/sim/tools/gitlab/list_repository_tree.ts New tool; correctly builds query params for path/ref/recursive/pagination
apps/sim/tools/gitlab/list_pipeline_jobs.ts New tool; reads x-total pagination header and applies scope/includeRetried filters correctly
apps/sim/tools/gitlab/get_job_log.ts New tool; correctly reads response as text (job log is plain text, not JSON)

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[GitLab Block UI] -->|operation selected| B{Operation Router\nconfig.tool}

    B -->|gitlab_list_repository_tree| C[list_repository_tree.ts\nGET /repository/tree]
    B -->|gitlab_get_file| D[get_file.ts\nGET /repository/files/:path\nBase64 decode]
    B -->|gitlab_create_file| E[create_file.ts\nPOST /repository/files/:path]
    B -->|gitlab_update_file| F[update_file.ts\nPUT /repository/files/:path]
    B -->|gitlab_list_branches| G[list_branches.ts\nGET /repository/branches]
    B -->|gitlab_create_branch| H[create_branch.ts\nPOST /repository/branches]
    B -->|gitlab_list_commits| I[list_commits.ts\nGET /repository/commits]
    B -->|gitlab_get_merge_request_changes| J[get_merge_request_changes.ts\nGET /merge_requests/:iid/changes]
    B -->|gitlab_approve_merge_request| K[approve_merge_request.ts\nPOST /merge_requests/:iid/approve]
    B -->|gitlab_list_pipeline_jobs| L[list_pipeline_jobs.ts\nGET /pipelines/:id/jobs]
    B -->|gitlab_get_job_log| M[get_job_log.ts\nGET /jobs/:id/trace]
    B -->|gitlab_play_job| N[play_job.ts\nPOST /jobs/:id/play]

    C & D & E & F & G & H & I & J & K & L & M & N -->|PRIVATE-TOKEN header| O[(GitLab API v4\nhttps://gitlab.com or self-hosted)]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[GitLab Block UI] -->|operation selected| B{Operation Router\nconfig.tool}

    B -->|gitlab_list_repository_tree| C[list_repository_tree.ts\nGET /repository/tree]
    B -->|gitlab_get_file| D[get_file.ts\nGET /repository/files/:path\nBase64 decode]
    B -->|gitlab_create_file| E[create_file.ts\nPOST /repository/files/:path]
    B -->|gitlab_update_file| F[update_file.ts\nPUT /repository/files/:path]
    B -->|gitlab_list_branches| G[list_branches.ts\nGET /repository/branches]
    B -->|gitlab_create_branch| H[create_branch.ts\nPOST /repository/branches]
    B -->|gitlab_list_commits| I[list_commits.ts\nGET /repository/commits]
    B -->|gitlab_get_merge_request_changes| J[get_merge_request_changes.ts\nGET /merge_requests/:iid/changes]
    B -->|gitlab_approve_merge_request| K[approve_merge_request.ts\nPOST /merge_requests/:iid/approve]
    B -->|gitlab_list_pipeline_jobs| L[list_pipeline_jobs.ts\nGET /pipelines/:id/jobs]
    B -->|gitlab_get_job_log| M[get_job_log.ts\nGET /jobs/:id/trace]
    B -->|gitlab_play_job| N[play_job.ts\nPOST /jobs/:id/play]

    C & D & E & F & G & H & I & J & K & L & M & N -->|PRIVATE-TOKEN header| O[(GitLab API v4\nhttps://gitlab.com or self-hosted)]
Loading

Comments Outside Diff (1)

  1. apps/sim/blocks/blocks/gitlab.ts, line 251-262 (link)

    P2 list_repository_tree missing ref input in block UI

    The underlying gitlab_list_repository_tree tool exposes an optional ref (branch/tag/commit) parameter, but neither the block's UI inputs nor the config.tool case forwards it. The block's existing ref field condition only covers ['gitlab_create_pipeline', 'gitlab_get_file', 'gitlab_create_branch'], leaving gitlab_list_repository_tree without a way to target a specific branch. As a result, all tree listings from the block always return the default branch, with no way for users to browse a feature branch's tree without using the tool directly.

Reviews (2): Last reviewed commit: "feat(gitlab): add repository, code-revie..." | Re-trigger Greptile

- get_merge_request_changes: use the /diffs endpoint (/changes was removed in
  GitLab 18.0); return the diff array + count (drops the MR envelope that /diffs
  no longer provides), fetch max page size in a single call
- create_file/update_file: send explicit `encoding: 'text'` for clarity
- Remove `// =====` separator comments from types.ts (repo convention)
- Regenerate GitLab integration docs + catalog for the 12 new tools
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Addressed all review feedback in 1e23b62f09:

  • P1 (/changes removed in 18.0): migrated get_merge_request_changes to GET /merge_requests/:iid/diffs (returns changes + changesCount; per_page=100 single call).
  • Cursor (file encoding): added explicit encoding: "text" to create/update file (GitLab’s default is already text per docs, so behavior was correct — this removes ambiguity).
  • Union completeness: the two branch response types were already in the GitLabResponse union (no change needed) — replied inline.
  • Buffer in get_file: kept — tools run in the Node executor (established pattern across s3/box/dataverse tools + the GitLab connector); atob would corrupt multi-byte UTF-8 and choke on base64 newlines.

Also removed // ===== separator comments from types.ts and regenerated the GitLab docs/catalog for the 12 new tools. Typecheck/biome/boundaries/api-validation/tests all clean.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1e23b62. Configure here.

@waleedlatif1 waleedlatif1 merged commit ae4bc05 into staging Jun 25, 2026
16 checks passed
@waleedlatif1 waleedlatif1 deleted the gitlab-validate-tools branch June 25, 2026 01:05
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.

1 participant