Strip only the literal properties/ prefix from GA property link IDs - #70919
Conversation
lstrip removes any leading character belonging to the given set, not a prefix, so the property ID itself could lose leading characters. This is correct today only because GA4 property IDs happen to be numeric; the intent is a prefix strip and should be expressed as one.
potiuk
left a comment
There was a problem hiding this comment.
Correct fix for a genuine latent trap. str.lstrip takes a character set rather than a prefix, so it also eats any leading p, r, o, e, t, i, s or / belonging to the ID:
properties/123456789 -> lstrip: 123456789 removeprefix: 123456789
properties/s123 -> lstrip: 123 removeprefix: s123
properties/porridge -> lstrip: dge removeprefix: porridge
I appreciate that the description is straight about this not being user-visible today — GA4 property IDs are numeric, digits are not in the strip set, so lstrip stops at the first digit and happens to give the right answer. Fixing the intent rather than claiming a live bug is the right framing.
The parametrized ("properties/s123", "s123") case is what makes this worth having: it returns "123" under the old implementation, so the test genuinely fails without the change instead of passing either way. Good that the inline comment records why that case exists, since it would otherwise look arbitrary. persist had no coverage at all before, so this closes that too.
One tidy-up before merge: the description has some leftover text — "removes the latent trap.Improve semantics and readability" — which reads like two drafts joined. Worth fixing, as the body becomes the squash commit message.
Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting
GoogleAnalyticsAdminCreatePropertyOperatorbuilds the property link ID withprop.name.lstrip("properties/").str.lstripremoves any leading characterbelonging to the given set — it is not a prefix strip — so it also consumes any
leading
p,r,o,e,t,i,sor/of the property ID itself.This is correct today only because GA4 property IDs are numeric, so there is no
user-visible behaviour change. The intent is a prefix strip, so
removeprefixexpresses it directly and removes the latent trap.Improve semantics and readability
The
persistcall had no test coverage; the added parametrized test pins theexact-prefix semantics and fails on the previous implementation.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines