Skip to content

Conversation

@scadu
Copy link
Contributor

@scadu scadu commented Jan 7, 2026

Description

Stumbled upon the issue while looking at the #613.
While the issue from #613 doesn't seem to be present anymore (tested using latest version 3.17.2), I discovered a different issue.
When using bk api without a leading slash (e.g., bk api "pipelines/dummy/builds/5085"), the endpoint was concatenated directly to the organization prefix, resulting in malformed URLs like v2/organizations/org-slugpipelines/dummy/builds/5085 instead of v2/organizations/org-slug/pipelines/dummy/builds/5085.

Changes

  • Extract endpoint building logic into buildFullEndpoint() function
  • Prepend / to endpoints that don't start with one
  • Add tests covering a few endpoint formats (with/without slash, analytics endpoints, empty endpoints, .etc.)

Testing

  • Tests have run locally (with go test ./...)
  • Code is formatted (with go fmt ./...)

Disclosures / Credits

I did not use "AI" tools at all.

When using `bk api` without a leading slash (e.g., `bk api
"pipelines/dummy/builds/5085"`), the endpoint was concatenated directly
to the organization prefix, resulting in malformed URLs like
`v2/organizations/org-slugpipelines/dummy/builds/5085` instead of
`v2/organizations/org-slug/pipelines/dummy/builds/5085`.

Changes:
- Extract endpoint building logic into `buildFullEndpoint()` function
- Prepend `/` to endpoints that don't start with one
- Add tests covering a few endpoint formats (with/without slash,
  analytics endpoints, empty endpoints, .etc.)
@scadu scadu requested a review from a team as a code owner January 7, 2026 09:13
@scadu scadu merged commit 402d81d into main Jan 7, 2026
1 check passed
@scadu scadu deleted the fix/leading_slash_api branch January 7, 2026 09:22
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.

3 participants