Skip to content

Remove AR_ACCOUNT_L1=legacy, a second key to L1 that nobody tracked - #22

Open
sumerjohal wants to merge 1 commit into
mainfrom
fix/remove-legacy-l1-flag
Open

sumerjohal wants to merge 1 commit into
mainfrom
fix/remove-legacy-l1-flag

Conversation

@sumerjohal

Copy link
Copy Markdown
Contributor

What

AR_ACCOUNT_L1=legacy turned any login into an L1 grant on the four field routes: /fetch-field, /fetch-field-wkt, /fetch-field-centroid and /geoid/{id}/eudr-export. Four identical lines in fetch_field.py:

if not has_l1 and os.getenv("AR_ACCOUNT_L1") == "legacy" and user is not None:
    has_l1 = True

It was a development convenience, documented nowhere (not in README, .env examples, CI or the deploy scripts), and would have been a production bypass had it ever been set there. The grant is the only thing that unlocks L1; a variable that also does is a second key nobody is tracking.

Change

The four lines and their local import os are removed. Nothing else reads the variable.

Tests

  • Two existing steps in test_api.py that asserted the flag unlocks L1 now assert it does not (L0), and clean up with try/finally. Both fail against main.
  • test_the_legacy_flag_unlocks_nothing_on_any_field_route: sets the flag, presents a valid login and no grant, requires the L0 answer on all four routes. Fails against main.
  • test_a_grant_still_unlocks_l1_so_the_refusal_above_is_a_refusal: same flag, same login, plus a real grant for the field; L1 on all four. So the L0 above is a refusal, not an outage.

harness/bin/stomata run: 12/12. Suite 174 passed, 1 xfailed (was 172). Lint 36, unchanged.

Operator note

If any deployment has AR_ACCOUNT_L1=legacy set, its logged-in users have been seeing L1 without a grant, and will see L0 after this merges. That is the intended behaviour; issue grants through Pancake.

Review finding A4, 2026-10-08.

Four identical lines in fetch_field.py turned any login into an L1 grant
on /fetch-field, /fetch-field-wkt, /fetch-field-centroid and
/geoid/{id}/eudr-export when the variable was set. It was a development
convenience, documented nowhere, and would have been a production bypass
had it ever been set there. The grant is the only thing that unlocks L1.

The lines and their local os imports are removed; nothing else reads the
variable.

Tests: the two test_api.py steps that asserted the flag unlocks L1 now
assert it does not, and fail against the previous code. A new test sets
the flag, presents a login and no grant, and requires L0 on all four
routes; its sibling adds a real grant and requires L1 on all four, so the
L0 is a refusal and not an outage.

stomata run: 12/12. Suite: 174 passed, 1 xfailed (was 172). Lint: 36, unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant