Skip to content

fix(pipelines): serialize array query params as key[] for GitLab Rails API#262

Merged
polaz merged 2 commits intomainfrom
fix/#261-array-query-params
Feb 2, 2026
Merged

fix(pipelines): serialize array query params as key[] for GitLab Rails API#262
polaz merged 2 commits intomainfrom
fix/#261-array-query-params

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Feb 2, 2026

Summary

  • buildQueryString() converted array values to comma-separated strings via String(), causing 400 Bad Request when job_scope or trigger_scope arrays were passed to GitLab REST API
  • Arrays now use searchParams.append() with key[] format (Rails convention): scope[]=failed&scope[]=success
  • toQuery() return type updated to preserve arrays through the serialization chain

Affected tools

Any tool passing array query params through toQuery() -> buildQueryString():

  • browse_pipelines jobs action (job_scope)
  • browse_pipelines triggers action (trigger_scope)
  • browse_members actions (user_ids)
  • browse_merge_requests list action (approved_by_ids)

Test plan

  • Unit tests: multi-element arrays produce scope[]=val1&scope[]=val2 (not scope=val1,val2)
  • Unit tests: single-element arrays use key[] format
  • Unit tests: trigger_scope array serialization
  • Integration tests: real API call with full job_scope array (the exact production failure)
  • Integration tests: real API call with trigger_scope array
  • Integration tests: edge case single-element scope array
  • All 420 tests passing (65 unit pipeline + integration suite)

Fixes #261

…s API

- buildQueryString() converted arrays to comma-separated strings via String(),
  causing "400 Bad Request - scope does not have a valid value" when job_scope
  or trigger_scope arrays were passed to GitLab API
- Arrays now use searchParams.append() with key[] format (Rails convention)
- toQuery() updated to preserve array types through the serialization chain
- Added unit tests verifying multi-element arrays produce scope[]=val1&scope[]=val2
- Added integration tests calling real API with job_scope and trigger_scope arrays

Fixes #261
Copilot AI review requested due to automatic review settings February 2, 2026 03:34
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 2, 2026

Test Coverage Report

Overall Coverage: 95.56%

Metric Percentage
Statements 95.01%
Branches 85.74%
Functions 94.63%
Lines 95.56%

View detailed coverage report

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/utils/gitlab-api.ts 83.33% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug where array query parameters were incorrectly serialized as comma-separated strings (e.g., scope=failed,success) instead of using the Rails key[] format required by GitLab's API (e.g., scope[]=failed&scope[]=success). This caused 400 Bad Request errors when using array parameters with tools like browse_pipelines, browse_members, and browse_merge_requests.

Changes:

  • Updated buildQueryString() to serialize arrays using Rails convention with key[] format
  • Modified type definitions to properly support array query parameters (QueryParamArray, QueryParams)
  • Added comprehensive unit and integration tests validating array serialization

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/utils/gitlab-api.ts Fixed array serialization in buildQueryString() and updated type definitions to support array query params
tests/unit/entities/pipelines/registry.test.ts Added unit tests for single and multi-element array serialization with job_scope and trigger_scope
tests/integration/schemas/pipelines.test.ts Added integration tests against real GitLab API with job_scope and trigger_scope arrays, including edge cases

@polaz polaz requested a review from Copilot February 2, 2026 03:53
@polaz polaz merged commit 955a3c1 into main Feb 2, 2026
26 of 27 checks passed
@polaz polaz deleted the fix/#261-array-query-params branch February 2, 2026 03:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

sw-release-bot bot pushed a commit that referenced this pull request Feb 2, 2026
## [6.51.0](v6.50.0...v6.51.0) (2026-02-02)

### Features

* **docs:** consent banner + vue-privacy 1.2.2 with gtag fix ([#255](#255)) ([75eb54b](75eb54b))

### Bug Fixes

* **ci:** prevent transitive skip propagation in release pipeline ([#266](#266)) ([f809a7a](f809a7a)), closes [#264](#264) [#265](#265) [#265](#265)
* **ci:** replace heredoc with quoted strings in thread-gate job ([#246](#246)) ([9470b50](9470b50)), closes [#243](#243) [#245](#245)
* **ci:** unblock release pipeline on push to main ([#264](#264)) ([59b8cbe](59b8cbe)), closes [#263](#263)
* **deps:** update hono from 4.11.5 to 4.11.7 ([#248](#248)) ([71cc831](71cc831)), closes [#247](#247)
* **docs:** resolve SEO issues in VitePress documentation ([#249](#249)) ([#250](#250)) ([3e05717](3e05717))
* **docs:** use canonical URL for TOOLS reference in README ([#252](#252)) ([5ac56cc](5ac56cc)), closes [#251](#251)
* **pipelines:** serialize array query params as key[] for GitLab Rails API ([#262](#262)) ([955a3c1](955a3c1)), closes [#261](#261)
@sw-release-bot
Copy link
Copy Markdown

sw-release-bot bot commented Feb 2, 2026

🎉 This PR is included in version 6.51.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array query params serialized as comma-separated string instead of key[] format

2 participants