Repository navigation
Tag import parent errors row and cycles (#892) - #925
ufedaseyeuconsultant wants to merge 3 commits into
Conversation
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]>
|
Thanks for the pull request, @ufedaseyeuconsultant! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Description
Improves two parent errors that the tag import shows at the Plan step, so a Platform Administrator re-importing a competency taxonomy can fix the file in one pass.
The unknown parent error names its row. "Unknown parent tag (tag_100). Add a row for the parent to your file." now starts with
Row N:, where N is the row's position among the file's data rows, counting from 1 (spreadsheet line N + 1 in a CSV). This is the same row number the stale parent error from #858 already shows. The#Nthat the error line starts with is the step's number in the Plan. That number counts every step in the Plan, deletes included, and rows are not built in file order, so it usually differs from the row number.ImportAction._validate_parentbuilds either of its two parent errors and applies theRow N:prefix once, at a single return, so the two errors cannot drift apart. Steps that no row describes, such as deletes and the moves to the root, have no row and validate no parent, so they are unaffected.Every parent cycle is reported as a cycle. Before it builds any row's action, the plan computes the tag tree as it will be after the import and walks it to find parent cycles (
TagImportPlan._validate_hierarchy). The walk reports every cycle that has a row in the file, once, on the cycle's first row:Row N's parent_id (X) creates a parent cycle.This includes a cycle made only of new tags, which the walk skipped before this change; the per-row check then reported one of its rows as an "Unknown parent tag" although the file has a row for that parent.A row on a cycle is not also reported as an unknown parent. The plan builds each row after the row that creates its parent, so the per-row check can find the parent among the actions built so far. In a cycle whose rows all create their parents or rename existing tags to the parents' ids, no order builds every row after its parent's row, so one of them is checked before its parent exists.
_validate_hierarchyrecords the rows of every cycle it reports inindexed_actions["_rows_on_a_cycle"], and_validate_parentreturns no unknown parent error for those rows. Skipping that error hides nothing, because every parent on a cycle is a tag of the final tree and the cycle error already rejects the import. The stale parent error from #858 is still reported for a row on a cycle.Which roles this affects: Platform Administrator, through the Studio taxonomy import wizard. Every file rejected before is still rejected; some now show fewer, clearer errors.
Supporting information
Testing instructions
pytest --no-cov tests/openedx_tagging/import_export/. The acceptance scenarios are inTestImportAcceptanceScenariosintest_api.py. Each one runs as a full replace import in several row orders.tag_100, with no row and no tagtag_100. The Plan step showsRow 4: Unknown parent tag (tag_100). Add a row for the parent to your file., and its step number#Nis different from 4.new_awith parent_idnew_bandnew_bwith parent_idnew_a. The Plan step shows exactly one error,Row 1's parent_id (new_b) creates a parent cycle., and no "Unknown parent tag" error.new_qwith parent_idtag_100. The Plan step shows the cycle error andRow 3: Unknown parent tag (tag_100). ....Other information
import_tagskeeps its signature and return value. No migration.docs:commit corrects theParentCycleErrordocstring: it said the row is 1-based "as in DuplicateFinalIdError", whose docstring does not state that. It now points atTagImportPlan._validate_no_duplicate_final_ids, which does.parent_idvalues by hand. Listing every row of the cycle in the error would change the acceptance criteria text, so it would need its own ticket.🤖 Generated with Claude Code