Skip to content

[WIP] Fix merging ties upload error in input_Nodes_Uses function#70

Merged
bischrob merged 1 commit into
mainfrom
copilot/fix-merging-ties-upload-error
Apr 15, 2026
Merged

[WIP] Fix merging ties upload error in input_Nodes_Uses function#70
bischrob merged 1 commit into
mainfrom
copilot/fix-merging-ties-upload-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Repo: ProjectCatMapper/CatMapperAPI

Bug:
Uploading a merging ties spreadsheet (3 columns: mergingID, stackID, datasetID) fails with:

"Missing MERGING tie between stackID and mergingID: [('AD1002', 'AD962')]"

Expected behavior:

  • When upload option is adding new merging ties for every row, if there is no existing MERGING relationship between the provided mergingID and stackID, the upload pipeline should create it rather than error.
  • Additionally, ensure a MERGING tie with no properties is created between every unique (datasetID, stackID) pair in the upload spreadsheet (deduplicated).

Context:
In CM/upload.py, input_Nodes_Uses() currently performs validation that raises if missing MERGING ties between stackID and mergingID (and between stackID and datasetID).
There is also create_mties_stacks() that creates ties between mergingID->stackID and stackID->datasetID, but the error occurs before creation when stackID is present in the input.

Required fix:

  1. Adjust the merging ties upload path so that when mergingType == "merging_ties_to_datasets" (uploadOption == "add_merging"), and the spreadsheet includes stackID, the pipeline will:

    • Create any missing MERGING tie between (mergingID -> stackID) with no properties.
    • Create any missing MERGING tie between (stackID -> datasetID) with no properties (deduplicated).
    • Then proceed without raising the "Missing MERGING tie..." error.
  2. Preserve existing validation for other merging types where missing ties should still error (unless explicitly intended otherwise).

  3. Add/adjust unit tests if the repo has a test suite; otherwise add a minimal regression test harness or clearly documented manual verification steps.

Acceptance criteria:

  • Uploading a spreadsheet containing rows with valid mergingID/stackID/datasetID where the MERGING ties don’t exist yet will succeed.
  • MERGING ties created have no extra properties.
  • Duplicates in spreadsheet do not create duplicates (use MERGE in Cypher and drop_duplicates in pandas).

Implementation hints:

  • Consider gating the existing check in input_Nodes_Uses():
    "checking existing MERGING ties between stackID and mergingID" and "checking MERGING ties between stackID and datasetID" so it doesn’t raise for mergingType == "merging_ties_to_datasets" in add_merging mode; instead create missing ties.
  • Reuse or refactor create_mties_stacks() logic for creating MERGING ties. Ensure matching labels are correct: MERGING nodes are :MERGING, stacks are :STACK (also labeled :DATASET), datasets are :DATASET.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: The upload function gives this error
Missing MERGING tie between stackID and mergingID: [('AD1002', 'AD962')]
The selection is Adding new merging ties for every row
There shouldn't be an error because if there is no MERGING tie between the stackID adn the mergingID then a MERGING tie between them should be created.
Fix this error so that a MERGING tie with no properties is created between every datasetID and stackID (deduplicated) in the upload spreadsheet, which has three columns: mergingID, stackID, and datasetID.

Assistant: I’ve kicked off the fix, and I’m waiting on your confirmation/approval from the dialog before I can proceed with applying the changes and finishing the update.

This pull request was created from Copilot chat.

@bischrob bischrob marked this pull request as ready for review April 15, 2026 23:24
@bischrob bischrob merged commit ce16252 into main Apr 15, 2026
1 check failed
Copilot AI requested a review from bischrob April 15, 2026 23:25
Copilot stopped work on behalf of bischrob due to an error April 15, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants