ontola / ontola/atomic-server

Importing hierarchical JSON-AD with local-id parents is order dependent

Open
#558 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.6k
Forks
82
Avg merge
10h 34m
Merged PRs (30d)
205

Description

Have a JSON-AD object that references a parent using a local-id, and the parent defined after that:

[
    {
        "https://atomicdata.dev/properties/localId": "child",
        "https://atomicdata.dev/properties/parent": "parent"
    },
    {
        "https://atomicdata.dev/properties/localId": "parent"
    }
]

We get an error:

Unable to import JSON-AD. Unable to parse resource in array. Unauthorized. No parent found for https://atomicdata.dev/importer/3cdk2343yrq/child

This happens, because the parent mentioned does not exist when the first resource is being parsed.

If we invert the order, we're good to go:

[
    {
        "https://atomicdata.dev/properties/localId": "parent"
    },
    {
        "https://atomicdata.dev/properties/localId": "child",
        "https://atomicdata.dev/properties/parent": "parent"
    }
]

How to deal with this

  • Improve error message, instruct users to use a specific import order (first the parents, then the children)
  • Automatically generate referenced parents as empty resources, they'll be overwritten later on automatically.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the JSON-AD array importer and reproduce the child-before-parent example from the issue. Compare it with the parent-before-child case, then clarify which proposed behavior is wanted: a clearer import-order error or support for referenced parents defined later. Done means the selected behavior is covered for both ordering cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.