tektoncd / tektoncd/pipelines-as-code

bitbucketdc: PR events use repository name instead of slug in API paths

Open Beginner friendly
#2,980 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
214
Forks
144
Avg merge
2d 11h
Merged PRs (30d)
27

Description

📝 Description

ParsePayload fills event.Repository from two different fields depending on the event.

Pull request events take the display name:

https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/parse_payload.go#L125

Push events take the slug:

https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/parse_payload.go#L145

Bitbucket keeps both on the repository object. name is what the UI shows, slug is the URL-safe form, and REST paths want the slug. Bitbucket derives one from the other, so for an ordinary lowercase name they are identical, which is why this has gone unnoticed. They diverge once the name carries capitals, spaces or punctuation: "My Repo" has slug my-repo.

Whatever lands in event.Repository feeds every API path the provider builds: acl.go lines 46 and 97, and bitbucketdatacenter.go lines 213, 232, 353, 359, 407, 450. On a repo where the two differ, pull request events request /repos/My%20Repo/... and get a 404 from ACL checks, GetFileInsideRepo, and the commit link built for SHAURL:

https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/bitbucketdatacenter.go#L359

Push events are unaffected.

🛠️ Suggested fix

Use .Slug at line 125. The field is already on the same struct.

The change alters event.Repository for anyone running with a divergent name, and that value reaches repository matching and annotations, not just URLs. Those users are already broken on the pull request path, so the change fixes them rather than regressing them, but it wants its own test.

There are no fixtures in pkg/provider/bitbucketdatacenter/ covering a name that differs from its slug, nor any covering personal repositories, where the project key keeps a ~ prefix.

I have not reproduced this against a live instance. The field semantics are clear from the payload types, and a repo created with a space in its name would confirm it from one webhook.

Found while reviewing #2975. That PR is not the cause; it surfaces a separate project-key problem on the same code path, which is being handled there.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg/provider/bitbucketdatacenter/parse_payload.go at line 125 and compare the repository fields used by pull request and push events. Inspect the existing tests and fixtures under pkg/provider/bitbucketdatacenter/, then add coverage for a repository whose name differs from its slug. Done means pull request API paths use the slug while push behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.