NASA-AMMOS / NASA-AMMOS/plandev

External plan uploads could trigger uniqueness violation on serial PK generator

Open
#836 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

clipper database
Dominant language
Java
Stars
128
Forks
33
Avg merge
1d 17h
Merged PRs (30d)
12

Description

Background

The addition of activity anchoring means that plans uploaded via the API either need to re-use the existing activity directive IDs as PKs (to preserve anchoring) or have all anchor IDs updated to match new directive IDs in the plan.

If a plan is uploaded with activity directive PKs that are larger than the state of the directive table serial ID generator, then it's possible that a user can encounter a uniqueness violation when trying to add activities to that plan in the future.

Steps to Reproduce

  • Create a plan with a single directive whose ID is generated by the serial ID generator in the database. Say that the ID of this directive is 1.
  • Via the API, add another directive to this plan, manually setting the ID to 3.
  • Via the UI, add one directive to the plan. The generator will assign ID 2 and the directive is created successfully.
  • Via the UI, try to add one more directive to the plan. The API call returns a uniqueness violation and the directive is not created.
  • Via the UI, try to add one more directive. The generator state has been incremented, so the directive is assigned ID 4 and is created successfully.

Actions

I don't need this resolved as I've already implemented a solution that uses the serial ID generator and re-maps anchored activities; I'm writing this ticket for awareness and documentation.

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 with the API and UI reproduction described in the issue, focusing on the serial ID generator and manually assigned directive IDs. No file, test, entry point, requested change, or completion criterion is provided; the issue says a solution has already been implemented elsewhere.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend, databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.