Skip to content

fix(backend/reqif): import Parent relations between different node types - #3243

Merged
stanislaw merged 1 commit into
strictdoc-project:mainfrom
cristianchiriac:fix-reqif-parent-foreign-id
Oct 18, 2026
Merged

stanislaw merged 1 commit into
strictdoc-project:mainfrom
cristianchiriac:fix-reqif-parent-foreign-id

Conversation

@cristianchiriac

Copy link
Copy Markdown
Contributor

Closes #3192.

When the converter imports a node with Parent relations, create_requirement_from_spec_object() keeps the definition ref of the child's ReqIF.ForeignID attribute and then reads the parent's UID with that same ref. Each grammar element is exported as its own spec object type, so the ref is different when the parent is another node type, for example a REQUIREMENT that traces to a NEED. The lookup then raised KeyError: 'REQUIREMENT_<id>_ReqIF.ForeignID' and the import of a file StrictDoc had just exported failed.

The converter now looks up the parent's spec object type and uses its own ReqIF.ForeignID definition to read the parent UID.

Test: the new integration test reqif/profiles/p01_sdoc/end_to_end/71_relations_between_node_types uses the grammar from the issue (a NEED and a REQUIREMENT with a Parent relation, role Traces). It exports the document to ReqIF, validates it, converts it back and compares the result with the input. On main the convert step fails with the KeyError; with this change the round trip gives back the same document. All 35 tests under tests/integration/features/reqif pass locally, and ruff check / ruff format --check are clean on the changed file.

The ReqIF to SDoc converter looked up the parent's ReqIF.ForeignID with
the child's attribute definition ref. Each grammar element gets its own
spec object type, so when the parent is another node type (for example a
REQUIREMENT tracing to a NEED) the lookup raised a KeyError and the
import failed. Look up the ForeignID definition in the parent's own spec
object type instead.

Closes #3192

@stanislaw stanislaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! One CI job has failed due to an unrelated flaky test which I am going to fix separately.

@stanislaw
stanislaw force-pushed the fix-reqif-parent-foreign-id branch from b3bcafb to c7b1e08 Compare October 18, 2026 15:15
@stanislaw
stanislaw merged commit 09019ab into strictdoc-project:main Oct 18, 2026
34 checks passed
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.

ReqIF import: KeyError on ReqIF.ForeignID for Parent relations between different grammar elements

2 participants