Skip to content

893 tag features into 892 - #951

Closed
nattynerdy wants to merge 5 commits into
openedx:mainfrom
nattynerdy:neuley/893-tag-features-into-892
Closed

nattynerdy wants to merge 5 commits into
openedx:mainfrom
nattynerdy:neuley/893-tag-features-into-892

Conversation

@nattynerdy

@nattynerdy nattynerdy commented Nov 19, 2026 •

Copy link
Copy Markdown

Summary by CodeRabbit

  • Bug Fixes
    • Tag imports now identify parent cycles clearly, including cycles involving new or renamed tags, without reporting misleading unknown-parent errors for rows in the cycle.
    • Imports now flag rows that reference a parent deleted by the same import, with the row number and parent ID to help correct the file.
    • Unknown-parent errors identify the affected row, including when multiple rows reference the same missing parent.
    • Children can still be moved to a retained parent when their former parent is deleted.

ufedaseyeuconsultant and others added 5 commits November 2, 2026 23:25
The unknown parent error at the Plan step named no row. Its only
locator was the step number #N, which counts every step in the Plan,
deletes included, and rows are not built in file order, so #N usually
differs from the row. An administrator could not tell which row to fix,
or tell apart several rows naming the same missing parent.

ImportAction._validate_parent now builds either of its two parent
errors, the stale parent error from openedx#858 or the unknown parent error,
and adds the "Row N: " prefix once, at a single return. Steps that no
row describes have no row and keep the unprefixed text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TagImportPlan._validate_hierarchy skipped a parent cycle made only of
new tags. The per-row check then reported one of its rows as an
"Unknown parent tag", although the file has a row for that parent.

The hierarchy walk now reports every cycle that has a row in the file,
once, on the cycle's first row. It records the 1-based rows of each
reported cycle in indexed_actions["_rows_on_a_cycle"], and
_validate_parent returns no unknown parent error for those rows, since
every parent on a cycle is a tag of the final tree. The stale parent
error is still reported for a row on a cycle. _validate_hierarchy drops
its pk_of parameter, which nothing in it reads any more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ParentCycleError docstring said its row is 1-based "as in
DuplicateFinalIdError", but that class's docstring does not state the
convention. TagImportPlan._validate_no_duplicate_final_ids does, so the
note now points there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#893)

A replace import deletes every tag the file has no row for. A row whose
parent_id named such a tag passed the plan, and the delete phase then
promoted the row's tag to the root, so the tag silently lost its parent.

The plan now checks each row against the tags it deletes. A parent_id
naming a deleted tag, with no tag of the final tree holding that id, is
reported on its row as DeletedParentError. A tag renamed onto the
deleted id holds it in the final tree, so such a row is accepted.

Changed outcome: a full replace file in which a kept tag's row names
its own parent, with no row for that parent, imported successfully
before and moved the tag to the root. That file is now rejected at the
Plan step. Imports with replace=False delete nothing and are unaffected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
)

Scenarios added to TestImportAcceptanceScenarios:
- a row naming a deleted parent is rejected when it moves a tag, keeps
  its deleted parent, creates a tag, renames a tag, spells the parent in
  another case, or names a tag inside a deleted chain
- every row naming a deleted tag gets its own error in one pass
- a kept child of a deleted tag moves under the kept tag its row names
- kept tags under deleted ancestors keep their content associations
- a child naming the id of a deleted holder in another case ends up
  under the tag renamed onto that id

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 19, 2026
@openedx-webhooks

openedx-webhooks commented Nov 19, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @nattynerdy!

This repository is currently maintained by @axim-engineering.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Submit a signed contributor agreement (CLA)

⚠️ We ask all contributors to the Open edX project to submit a signed contributor agreement or indicate their institutional affiliation.
Please see the CONTRIBUTING file for more information.

If you've signed an agreement in the past, you may need to re-sign.
See The New Home of the Open edX Codebase for details.

Once you've signed the CLA, please allow 1 business day for it to be processed.
After this time, you can re-run the CLA check by adding a comment below that you have signed it.
If the CLA check continues to fail, you can tag the @openedx/cla-problems team in a comment for further assistance.

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The import plan now reports file-row parent cycles and separates cycle errors from unknown-parent errors. In replace imports, it also rejects rows that reference a deleted parent not present in the final tree.

Changes: Tag import parent validation

Layer / File(s) Summary
Cycle and unknown-parent validation
src/openedx_tagging/import_export/actions.py, src/openedx_tagging/import_export/exceptions.py, src/openedx_tagging/import_export/import_plan.py, tests/openedx_tagging/import_export/test_actions.py, tests/openedx_tagging/import_export/test_api.py, tests/openedx_tagging/import_export/test_import_plan.py
The plan reports cycles containing file rows, including cycles among new tags. Cycle members do not receive duplicate unknown-parent errors. Other unknown-parent errors identify the source row. Tests cover cycles, unknown parents, and separate stale-parent errors.
Deleted-parent validation
src/openedx_tagging/import_export/exceptions.py, src/openedx_tagging/import_export/import_plan.py, tests/openedx_tagging/import_export/test_api.py, tests/openedx_tagging/import_export/test_import_plan.py
A new error identifies rows that reference a deleted parent absent from the final tree. Replace-mode tests cover multiple row types, case variants, deleted-parent chains, and parent moves. The tests also verify accepted references when the final tree contains the referenced ID.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Possibly related issues

  • openedx/openedx-core issue 893: The PR adds replace-import validation for rows that reference a deleted parent.
  • openedx/openedx-core issue 892: The PR reports parent-cycle errors for cycles among new tags and includes source-row information in parent errors.

Suggested reviewers: ufedaseyeuconsultant, kdmccormick, bradenmacdonald

Merge Risk: Minimal · up to 2673e

Tag imports now give clearer, row-specific errors for parent cycles and unknown parents. They also reject rows that name a parent the same replace import deletes. Full replace files that previously moved such tags to the root will now be rejected, which is the stated intent. No merge-blocking code risk was found; the contributor agreement check still needs to be resolved.

Security architecture risk: Minimal · up to 2673e

The change rejects invalid parent references before tag mutations execute. Existing taxonomy access checks and transactional execution remain in place. No introduced or worsened risk to security, failure containment, rollback, or ownership was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed validation affects imports into the selected taxonomy, including replacement imports capable of deleting omitted tags. The inspected flow does not introduce a broader cross-taxonomy lookup or mutation authority: plans carry one taxonomy and parent lookup uses that taxonomy’s tag relation.

Trust Boundaries and Controls

  • observed — Replacement-import and planning requests validate uploaded request data and obtain the target taxonomy through get_object(), which invokes object-permission checks. Uploaded parent references then pass through plan validation before reaching tag mutation actions. The PR changes those validation decisions, not the inspected access-control path.

Resilience and Maintainability Implications

  • observed — Execution retains its atomic transaction and error guard. Regenerating a plan clears prior actions, errors, and indexed metadata. Inspected tests assert unchanged tag identities and hierarchy after rejected deleted-parent or cycle inputs, and preserve acceptance when a renamed tag reclaims a deleted parent’s ID. These assertions were inspected, not executed.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants