Skip to content

fix(catalogue): apoc.convert.fromJsonMap throws query-wide on malformed range value #419

Description

@JanSmrcka

Context

In `services/catalogue-service/catalogue-db-queries.go` the range-typed property logic uses:

```cypher
apoc.convert.fromJsonMap(pv.value)
```

Two locations:

`apoc.convert.fromJsonMap` on a malformed string throws a Cypher-level exception — the whole query 500s, not just the one row.

Why this matters now

PR #416 made range-typed properties sortable, which means a single bad-data row in any item that has a range custom property → entire list endpoint dies whenever someone sorts by that column.

Mitigation options

  1. Defensive parse: switch to a lenient JSON helper or wrap in `apoc.do.when` with a fallback to null.
  2. Type-coerce-and-skip: `CASE WHEN pv.value STARTS WITH '{' THEN apoc.convert.fromJsonMap(pv.value).min ELSE null END` — handles the most common bad-data case (empty string).
  3. Backfill: data audit + normalize all range values to valid JSON.

Option 2 is the cheapest defensive fix.

Acceptance

  • Inject a row with `pv.value = 'bogus'` for a range property; the sort + filter queries still return 200.
  • Item appears at the head/tail (null sort) instead of crashing the response.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions