The Test Code Samples job has failed on every run since 2025-11-10. The
fleet-management-api-orgs.py sample picked member_list[-1] for the
add_role/change_role/remove_role sequence, but the test org's membership
changed so that the last member is now an org owner. Org owners inherit
location_owner, so add_role(role="owner", resource_type="location") is
rejected with:
GRPCError(INTERNAL, "cannot add authorization: user ... has inherited
location_owner permissions on resource ... with resource type location")
Select a member who holds no existing authorizations instead of relying on
list position, so add_role grants a genuinely new authorization regardless
of member ordering. Assert clearly if no such member exists.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem
The Test Code Samples job (
test-code-snippets.yml) has failed on every run since 2025-11-10 — both the weekly scheduled runs and every dependabot/push run. Because the Python step runs first and exits non-zero, the Go and TypeScript sample steps never run, so this also blocks validation of unrelated dependency bumps.The single failing file is
static/include/examples/fleet-api/fleet-management-api-orgs.py. Today's run: 28/29 Python samples pass; this one fails at theadd_rolecall (line ~197):Root cause
The sample selected
member_list[-1](the last org member) for theadd_role → change_role → remove_rolelifecycle. Member ordering isn't guaranteed, and the test org's membership has since changed so the last member is now an org owner. Org owners inheritlocation_owneron every location, so adding a location-levelownerrole to them is rejected by the backend.This is an environmental regression, not a code change — the file was unchanged when the job went red on Nov 10 (the next edits to it were Nov 13/27/28, after it was already failing).
Fix
Select a member who holds no existing authorizations (so they can't inherit
location_owner) instead of relying on list position:add_rolethen grants a genuinely new authorization regardless of member ordering, and the downstreamchange_role/remove_roleand count assertions hold. If no roleless member exists, the new assert fails with a clear message instead of a crypticGRPCError.Verification
python -m py_compilepasses; AST parses.VIAM_API_KEY/TEST_ORG_ID/etc., which are GitHub Actions secrets unavailable locally. Please confirm via the Test Code Samples workflow on this branch (or a maintainer re-run) that the org has at least one member without existing authorizations. If the test org happens to contain only owners, the new assert will surface that explicitly and a non-owner member should be added to the org.🤖 Generated with Claude Code