Skip to content

Commit 78fc0c7

Browse files
thjaeckleclaude
andcommitted
Fix 3-level reference resolution: resolve imported policy's references before importing
When importing a policy whose entries use references (e.g. fleet-west's driver references fleet-roles's driver for resources), the references must be resolved BEFORE the entries are imported and references stripped. Previously, resolveImport would merge transitive entries then immediately rewrite labels (stripping references via the 6-arg factory), losing the resource/subject inheritance that references provided. Now, resolveReferences is called on the loaded policy's entries after transitive merge but before label rewriting, materializing the inherited values. This fixes the 3-level hierarchy scenario (template → intermediate → leaf) where Alice (subject on intermediate) could not access resources defined on the template. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 02aa727 commit 78fc0c7

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

policies/model/src/main/java/org/eclipse/ditto/policies/model/PolicyImporter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,16 @@ private static CompletionStage<Set<PolicyEntry>> resolveImport(
140140
resolvedEntriesCs = CompletableFuture.completedFuture(loadedPolicy.getEntriesSet());
141141
}
142142
return resolvedEntriesCs.thenApply(resolvedEntries -> {
143+
// Resolve the loaded policy's own entry references before importing.
144+
// This ensures entries that inherit resources/subjects via references
145+
// have those values materialized before the references are stripped
146+
// during label rewriting.
147+
final Set<PolicyEntry> withResolvedRefs =
148+
resolveReferences(loadedPolicy, resolvedEntries);
143149
final ImportedLabels importedLabels = policyImport.getEffectedImports()
144150
.map(EffectedImports::getImportedLabels)
145151
.orElse(ImportedLabels.none());
146-
return rewriteImportedLabels(importedPolicyId, resolvedEntries,
152+
return rewriteImportedLabels(importedPolicyId, withResolvedRefs,
147153
importedLabels, applyImportPrefix);
148154
});
149155
}).orElse(CompletableFuture.completedFuture(Collections.emptySet())));

0 commit comments

Comments
 (0)