Skip to content

ref(hybridcloud): Read webhook bucket keys through one helper - #123678

Open
vaind wants to merge 2 commits into
masterfrom
ivandlugos/read-bucket-keys-uniformly
Open

ref(hybridcloud): Read webhook bucket keys through one helper#123678
vaind wants to merge 2 commits into
masterfrom
ivandlugos/read-bucket-keys-uniformly

Conversation

@vaind

@vaind vaind commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Five parsers each read the id their mailbox is bucketed on, and each one disagreed about what to do with a body it did not expect.

  • github required an int, so a payload sending "1" fell back to the unsplit mailbox.
  • gitlab returned the value uncoerced, so a string id raised TypeError at the modulo, and a non-dict project raised AttributeError before ever getting there.
  • jira_server caught ValueError but not TypeError, so {"issue": {"id": []}} raised out of the parser.
  • jira and vsts were already right, and the shared reader is exactly what they did.

BaseRequestParser.bucket_key_at(data, *path) is that: read the value, coerce it to an int, fall back to the integration-level mailbox on anything else. All five go through it now.

What changes

An unusable key falls back instead of raising, in the three parsers that did not already do that. It also stops discarding id 0 -- gitlab and jira_server tested the value for truthiness, and 0 is the first bucket of a split, not the absence of one.

None of it fires on a real payload, per each provider's own docs. GitHub types repository.id as a required integer, format: int64 -- never a string, which is what made that fixture wrong. GitLab types project.id as an integer and omits project entirely on group-scoped events, which both the old reader and this one answer with the integration-level mailbox. Jira Server is the one provider whose issue.id really does arrive as a string ("id": "99291"), and its reader already coerced it.

So no mailbox name moves on deploy. Every branch this changes is reached only by a payload shape no provider sends, which is the point: they were five different answers to a case none of them had.

Reviewer notes

One GitHub fixture claimed "repository": {"id": "1"}. Real payloads send a number -- the cell handler does str(event["repository"]["id"]) -- so the fixture was wrong and is now 1, which is what every other GitHub test already used. That is the one test whose mailbox name moves: test_issue_deleted_routing was landing on github:<id>:issues because the string was rejected, and now lands on github:<id>:1:issues like every other repository-carrying payload.

The gitlab mailbox_bucket_id unit test comes from the gate-removal PR (#123449), where its coercion and non-dict-project cases were asserting this helper rather than that one.

Refs CW-1987

@vaind
vaind requested a review from a team as a code owner September 4, 2026 09:27
@linear-code

linear-code Bot commented Sep 4, 2026

Copy link
Copy Markdown

CW-1987

The unit test came off the gate-removal PR, where its coercion and non-dict
cases were asserting this helper's behaviour rather than that one's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant