fix(pipelines): serialize array query params as key[] for GitLab Rails API#262
fix(pipelines): serialize array query params as key[] for GitLab Rails API#262
Conversation
…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
Test Coverage ReportOverall Coverage: 95.56%
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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 withkey[]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 |
## [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)
|
🎉 This PR is included in version 6.51.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
buildQueryString()converted array values to comma-separated strings viaString(), causing400 Bad Requestwhenjob_scopeortrigger_scopearrays were passed to GitLab REST APIsearchParams.append()withkey[]format (Rails convention):scope[]=failed&scope[]=successtoQuery()return type updated to preserve arrays through the serialization chainAffected tools
Any tool passing array query params through
toQuery()->buildQueryString():browse_pipelinesjobs action (job_scope)browse_pipelinestriggers action (trigger_scope)browse_membersactions (user_ids)browse_merge_requestslist action (approved_by_ids)Test plan
scope[]=val1&scope[]=val2(notscope=val1,val2)key[]formatjob_scopearray (the exact production failure)trigger_scopearrayFixes #261