Skip to content

Fix --json-path scoping and validation for URL inputs #219

Description

@vmvarela

Problem

--json-path already selects the nested array used as rows for JSON input, but its current validation does not correctly account for per-URL --input-format.

This valid command can fail because -I json is attached to the preceding URL while --json-path validation checks only the global input format:

sql-pipe --url https://api.example.com/items -I json --json-path data.items 'SELECT * FROM url0'

--json-path is also global, while --input-format and --http-header support per-URL configuration.

Proposed Behavior

  • --json-path after a --url applies to that URL.
  • --json-path before any URL remains the global value for files and stdin.
  • A URL-specific path overrides the global path.
  • Different JSON URLs may use different row-array paths.
  • The path remains simple dot-separated key navigation, not full JSONPath.
sql-pipe --url users=https://api.example.com/users -I json --json-path data.users --url orders=https://api.example.com/orders -I json --json-path results.orders 'SELECT * FROM users JOIN orders ON users.id = orders.user_id'

Acceptance Criteria

  • Store an optional JSON path in each UrlInput.
  • Pass the URL-specific path to the JSON loader.
  • Fall back to the global path when no URL-specific path exists.
  • Accept --url ... -I json --json-path ....
  • Reject URL-specific paths for explicitly non-JSON URL inputs.
  • Preserve existing behavior when --json-path is omitted.
  • Add integration tests for one URL, multiple URLs, fallback, and invalid formats.
  • Update help, completions, README, and man page.
  • Do not add full JSONPath, flattening, or column-level path mappings.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:mediumShould be done soonsize:sSmall — 1 to 4 hoursstatus:readyRefined and ready for sprint selectiontype:bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions