Skip to content

Name the vehicle's position in its state: its place, or its address - #439

Merged
vcanuel merged 1 commit into
mainfrom
feat/state-place-address
Nov 20, 2026
Merged

vcanuel merged 1 commit into
mainfrom
feat/state-place-address

Conversation

@vcanuel

@vcanuel vcanuel commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

GET /api/v1/vehicles/{vehicle}/state gave the vehicle's position only. It now gives, beside it, what a trip gives of its ends:

  • place: the account's nearest place whose circle holds the position (PlaceRef, as a trip's start_place); null without a position and outside every place.
  • address: the street and town of the position, from the instance's reverse geocoder, outside every place (as a trip's start_address); null at a place, without a geocoder, when it knows none, and until it answered.

Both are computed by the trips' code (placeAt, Server.addresses) and share their cache of geocoded positions (geocoded_positions, one row per account and cell, ON CONFLICT DO NOTHING): a parked vehicle read every minute has its cell geocoded once. The places are read only when the state has a position.

Both fields are required and nullable in State; api/openapi.yaml and the state's golden files are regenerated.

Tests

  • TestStatePlace: a place, an address outside places, null at a place, an unknown address asked for a later read, no position, no geocoder.
  • task unit-go (0 lint issues), task lint-api, TestGeocoding on PostgreSQL, task web-lint, task web-test.

Closes #438

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • State information now includes the place associated with the current position, when one is available.
    • When no matching place is found, state information can include the position’s address. Unknown addresses may be requested for lookup.
    • If there is no current position, place and address information remain absent.

GET /vehicles/{vehicle}/state gives, beside position, what a trip gives of
its ends: place, the account's nearest place whose circle holds it, and
address, the instance's reverse geocoder's answer outside every place. Both
come from the same code and the same cache of geocoded positions as the
trips': a parked vehicle read every minute has its cell geocoded once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The vehicle state response now includes place and address for the current position. The API resolves the nearest matching account place and obtains the address through the instance address book. Tests cover place matches, address lookup, and cases with no position or geocoder.

Changes: Vehicle State Location

Layer / File(s) Summary
State fields and location resolution
internal/api/read.go, internal/api/addresses_test.go
The state response adds place and address. When a position is available, getState loads account places and resolves the matching place and address. Tests cover place matches, geocoded and unknown addresses, no position, and no geocoder. They also check lookup requests.

Possibly related issues

  • The reverse-geocoder country issue is adjacent because this change exposes its existing street-and-town address in vehicle state. This change does not add country data.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 22092

The vehicle state response gains nullable place and address fields for the current position. No actionable merge-blocking risk was found, and the change is additive.

Pre-merge checks: Passed 2 · Inconclusive 2

Failed Failed checks: 2 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title "Name the vehicle's position in its state: its place, or its address" describes the change: the vehicle state now names the position through a place or an address. It does not follow the con… Shorten the title and state the user-facing action. For example: "Add place and address to vehicle state". This matches the configured imperative style and names the new fields.
Linked Issues check Inconclusive Linked issue #438 is the only active direct target. Its coding requirements are: (1) place and address in State; (2) place and address in api/openapi.yaml; (3) a test for both fields; (4) … Confirm that api/openapi.yaml declares place and address as required, nullable fields of State, as the PR description states. Provide the diff or reviewable evidence of the geocoded_positions reuse in the state path (the shared `p…
Passed Passed checks: 2 passed

Check name Status Explanation
Description check Passed The description explains what changed and why: the state endpoint now returns place and address beside position, and the shared geocoding cache is reused. It lists the tests and checks that were run, …
Out of Scope Changes check Passed The reviewed change summaries cover internal/api/read.go (+16 lines) and internal/api/addresses_test.go (+76 lines). Both changes add the state's place and address fields and their test, which…
Full details: Description check

Explanation

The description explains what changed and why: the state endpoint now returns place and address beside position, and the shared geocoding cache is reused. It lists the tests and checks that were run, and links issue #438. It does not tick the template's checklist items, such as confirming the API diff is intended and that no real VIN, token, or position fixtures are included. The description also does not mention translations, and the template says these apply only if the interface changed.

Full details: Out of Scope Changes check

Explanation

The reviewed change summaries cover internal/api/read.go (+16 lines) and internal/api/addresses_test.go (+76 lines). Both changes add the state's place and address fields and their test, which #438 requests. The excluded files (api/openapi.yaml and the internal/api/testdata/state*.json golden files) are regenerated artifacts for the same fields. They are not evidence of unrelated work. No summary shows removed lines or changes to trips' behavior, so no unrelated change is demonstrated. The summaries may not list every file, so this verdict covers only the reviewed summaries.

Full details: Title check

Explanation

The title "Name the vehicle's position in its state: its place, or its address" describes the change: the vehicle state now names the position through a place or an address. It does not follow the configured requirement of a short, imperative, English title starting with a verb such as "Add" or "Fix". It uses a noun phrase ("Name the ..." is imperative, but the title is a long, colon-separated phrase of 12 words), and it does not say the fields are new to the API response.

Resolution

Shorten the title and state the user-facing action. For example: "Add place and address to vehicle state". This matches the configured imperative style and names the new fields.

Full details: Linked Issues check

Explanation

Linked issue #438 is the only active direct target. Its coding requirements are: (1) place and address in State; (2) place and address in api/openapi.yaml; (3) a test for both fields; (4) the geocoder requests shared with the trips' cache, so a parked vehicle read every minute asks once; (5) address null until the geocoder answers, and resolved for a later read.

Evidence for (1), (3), and (5): the change summary for internal/api/read.go says stateJSON gains place and address. getState loads places only when a position exists, resolves the nearest containing place, and gets the address through the instance address book (Server.addresses). The summary for internal/api/addresses_test.go lists TestStatePlace, which covers a place, an outside-place address, null at a place, an unknown address requested on a later read, no position, and no geocoder.

Evidence for (4): the PR description states that both fields use geocoded_positions with ON CONFLICT DO NOTHING. The change summaries do not show this cache code. This is a claim from the description, not verified in code.

Requirement (2) depends on api/openapi.yaml. That path is in ignored_files (excluded by rule !api/openapi.yaml), so its content cannot be reviewed. The same applies to the state golden files under internal/api/testdata/, excluded by !**/testdata/**.

The core Go implementation appears to meet the requirements. The OpenAPI requirement and the shared-cache behavior are not independently established.

Resolution

Confirm that api/openapi.yaml declares place and address as required, nullable fields of State, as the PR description states. Provide the diff or reviewable evidence of the geocoded_positions reuse in the state path (the shared placeAt and Server.addresses call sites with the cache insert). Then reassess.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f85fef1 and 22092b0.

Files ignored due to path filters: 7

  • api/openapi.yaml is excluded by !api/openapi.yaml
  • internal/api/testdata/state-charge-details.json is excluded by !**/testdata/**
  • internal/api/testdata/state-climate.json is excluded by !**/testdata/**
  • internal/api/testdata/state-openings.json is excluded by !**/testdata/**
  • internal/api/testdata/state-software.json is excluded by !**/testdata/**
  • internal/api/testdata/state-unknown.json is excluded by !**/testdata/**
  • internal/api/testdata/state.json is excluded by !**/testdata/**
Files selected for processing: 2

  • internal/api/addresses_test.go
  • internal/api/read.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@vcanuel
vcanuel merged commit 92b25c3 into main Nov 20, 2026
11 of 13 checks passed
@vcanuel
vcanuel deleted the feat/state-place-address branch November 20, 2026 22:13
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.

The vehicle's state names its place, or its address

1 participant