Problem
EdgeDevice.location is CharField(choices=ZONE_CHOICES) (electricityMaps zones — https://api.electricitymap.org/v3/zones), so the backend serializer's ChoiceField rejects any value not in the list. The CLI doesn't validate --location / the location prompt against that list, so an invalid value (Germany, germany, eu-central-1, a typo) only fails at create time as a raw 400 — poor UX.
The location auto-detect (cli#93) always produces a valid zone (an ISO country code), so the happy path is fine. This is about the override / explicit---location path.
Proposal
Vendor ZONE_CHOICES into the CLI (the same way the ingestion schema is vendored via scripts/sync-schema.sh) and use it to:
- Validate
--location and the interactive prompt input against the zone list — fail fast with a helpful message instead of a backend 400.
- Offer a picker in the interactive flow (the
prompter.Select seam already exists), or at least suggest close matches on a miss (Germany → did you mean DE?).
- Keep cli#93's auto-detect feeding the default; validation just guards overrides + the flag.
Scope / notes
- A sync script (e.g.
scripts/sync-zones.sh) pulling ZONE_CHOICES keeps the CLI list in lock-step — same pattern as the schema sync. Decide source of truth: the backend's metaApi/models/zone_choices.py vs the upstream electricityMaps zones endpoint.
- ~400 zones (countries + sub-zones like
US-CAL-CISO, AU-NSW); a picker over that many needs search/filter (survey supports it).
Refs
RFC-0001 #830 · cli#92 (client commands) · cli#93 (location auto-detect) · backend metaApi/models/zone_choices.py. Found during the cli#93 build.
Problem
EdgeDevice.locationisCharField(choices=ZONE_CHOICES)(electricityMaps zones — https://api.electricitymap.org/v3/zones), so the backend serializer'sChoiceFieldrejects any value not in the list. The CLI doesn't validate--location/ the location prompt against that list, so an invalid value (Germany,germany,eu-central-1, a typo) only fails at create time as a raw 400 — poor UX.The location auto-detect (cli#93) always produces a valid zone (an ISO country code), so the happy path is fine. This is about the override / explicit-
--locationpath.Proposal
Vendor
ZONE_CHOICESinto the CLI (the same way the ingestion schema is vendored viascripts/sync-schema.sh) and use it to:--locationand the interactive prompt input against the zone list — fail fast with a helpful message instead of a backend 400.prompter.Selectseam already exists), or at least suggest close matches on a miss (Germany→ did you meanDE?).Scope / notes
scripts/sync-zones.sh) pullingZONE_CHOICESkeeps the CLI list in lock-step — same pattern as the schema sync. Decide source of truth: the backend'smetaApi/models/zone_choices.pyvs the upstream electricityMaps zones endpoint.US-CAL-CISO,AU-NSW); a picker over that many needs search/filter (survey supports it).Refs
RFC-0001 #830 · cli#92 (client commands) · cli#93 (location auto-detect) · backend
metaApi/models/zone_choices.py. Found during the cli#93 build.