Skip to content

docs: GET /api/maps/preview-sources/:sourceId/field-values endpoint missing from behaviors.md #378

Description

@evan-zhang11

Problem

The field values endpoint GET /api/maps/preview-sources/:sourceId/field-values is implemented in backend/src/map_handlers.rs (handler get_field_values) and registered in backend/src/routes.rs, but is not documented in any behavior contract entry in docs/dev/behaviors.md.

Implementation Details

Route: GET /api/maps/preview-sources/{sourceId}/field-values

Query Parameters:

  • field (required, string) — The field/column name to fetch values for
  • limit (optional, integer, default: 50, max: 500) — Maximum number of distinct values to return

Authentication: Required

Behavior:

  1. Looks up the file by sourceId in the current workspace
  2. Returns 404 if source not found, 409 if not ready
  3. Returns 400 if source has no import table (e.g., MBTiles) or is not a DuckDB source
  4. For numeric fields (Int/Float/Double types):
  5. For non-numeric fields:
    • Returns distinct string values up to limit

Response (numeric):

{
  "field": "population",
  "values": [100, 200, 300],
  "type": "Double",
  "min": 0.0,
  "max": 999999.0,
  "sortedValues": [0.0, 1.5, 2.3, ...]
}

Response (non-numeric):

{
  "field": "name",
  "values": ["Alice", "Bob"],
  "type": "String"
}

Errors: 400 (empty field / non-DuckDB source), 401, 404, 409 (not ready)

Related Issues

Proposed Action

Add a behavior contract entry (e.g., MAP-001 or API-023) documenting:

  • Query parameters and their constraints
  • Response schema for numeric vs non-numeric fields
  • Error responses and status codes
  • The field type detection logic (based on dataset_columns.mvt_type)

Priority: P2 — Endpoint is functional but has known performance issues (#351, #363). Documentation should note these as known limitations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions