Skip to content

[Bug]: bk api duplicates organization in URL path #613

@kylesnowschwartz

Description

@kylesnowschwartz

Contact details

https://github.com/kylesnowschwartz

What happened?

The bk api command incorrectly duplicates the organization slug in the URL path when making API requests.

Expected URL:

https://api.buildkite.com/v2/organizations/envato-marketplaces/pipelines/author-warehouse/builds/4815/jobs/JOB_ID/log

Actual URL (results in 404):

https://api.buildkite.com/v2/organizations/envato-marketplaces/organizations/envato-marketplaces/pipelines/author-warehouse/builds/4815/jobs/JOB_ID/log

Reproduction

export BUILDKITE_API_TOKEN="your-token"
export BUILDKITE_ORGANIZATION_SLUG="envato-marketplaces"

# This fails with 404 due to duplicated /organizations/envato-marketplaces/
bk api "pipelines/author-warehouse/builds/4815/jobs/019b91ce-2d8a-43fd-8f04-525409d9ac4f/log"

Error:

Error: error making request: HTTP request failed: 404 404 Not Found 
(https://api.buildkite.com/v2/organizations/envato-marketplaces/organizations/envato-marketplaces/pipelines/...): {"message":"Not Found"}

Version

$ bk version
bk version 3.5.0

Environment

macOS (Darwin 24.6.0)

Workaround

Calling the REST API directly with curl works correctly:

curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
  "https://api.buildkite.com/v2/organizations/envato-marketplaces/pipelines/author-warehouse/builds/4815"

Expected behavior

bk api should construct the URL correctly without duplicating the organization slug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions