feat: validate referenced entry content types in entries audit#2424
Merged
cs-raj merged 2 commits intov2-beta-devfrom Feb 24, 2026
Merged
feat: validate referenced entry content types in entries audit#2424cs-raj merged 2 commits intov2-beta-devfrom
cs-raj merged 2 commits intov2-beta-devfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(audit): Validate reference content types against schema in entries audit
Problem
The entries audit only verified that referenced entry UIDs exist in the export. It did not validate that the referenced entry's content type matched the schema's
reference_to. This allowed invalid references to pass audit, e.g.:reference_to: ["ct1"]could reference ct2 entries and passreference_to: ["ct1", "sys_assets"]could embed ct2 entries and passThese invalid references could cause import failures.
Solution
Add content-type validation so that when a reference exists in
entryMetaData, the audit also checks that the referenced entry's content type is allowed byreference_to. Invalid references are now reported and can be fixed.Changes
isRefContentTypeAllowed(refCtUid, referenceTo, config?)to centralize the content-type checkvalidateReferenceValues, when ref exists, validate content type and report if invalidjsonRefCheck, when ref exists, validate content type and report if invalidfixMissingReferences, filter out refs with invalid content type and record in missingRefsjsonRefCheck, returnnullwhen CT invalid in fix mode so fix path removes the embedEdge Cases Handled
reference_toundefined/nullreference_tostring[reference_to]reference_toempty arrayrefCtUidundefinedrefCtUidinskipRefs(e.g.sys_assets)"blt..."refExist.ctUidfrom metadata{ uid, _content_type_uid }_content_type_uid, fallbackrefExist.ctUidcontent-type-uid(kebab-case)Testing
isRefContentTypeAllowed, 3 forvalidateReferenceValues, 1 for JSON RTE audit, 1 forfixMissingReferences, 1 forjsonRefCheckfix modeFiles Changed
packages/contentstack-audit/src/modules/entries.ts– implementationpackages/contentstack-audit/test/unit/modules/entries.test.ts– unit tests