Skip to content

validate: treat an uncomposed manifest cluster as @absent (#127)#129

Merged
orian merged 1 commit into
mainfrom
fix/127-uncomposed-cluster-absent
Jul 8, 2026
Merged

validate: treat an uncomposed manifest cluster as @absent (#127)#129
orian merged 1 commit into
mainfrom
fix/127-uncomposed-cluster-absent

Conversation

@orian

@orian orian commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Closes #127.

Bug

A cluster block whose member roles have no composition in the selected -env unioned to zero databases but was still cs.Added — registering an empty-but-mapped cluster. resolveDistributedRemote checks mapped before absent, so every proxy into it failed with a false "not declared in that cluster's schema" instead of being treated as absent.

Corollary: -cluster NAME=@absent couldn't override a manifest-declared cluster — AddAbsent left the manifest's declared entry and the mapped check short-circuited.

Reproduced first (both bugs) with failing tests, then fixed.

Fix

  • clusterSetFromRoles (cmd/hclexp/hclexp.go): when a cluster's member-role union is empty for the env, register it via AddAbsent (it's modeled elsewhere / env-varying), not Add.
  • ClusterSet.Add/AddAbsent/AddAlias (internal/loader/hcl/clusterset.go) now clear the other categories for a name, so a name is in exactly one category and the latest writer wins — making -cluster NAME=@absent reliably override a manifest cluster (and a real mapping override a prior absent).

Tests

  • TestValidateManifest_UncomposedClusterIsAbsent — proxy into an uncomposed cluster is satisfied (was the false error).
  • TestValidateManifest_ComposedClusterValidates — same cluster in an env where its role is composed validates normally.
  • TestValidateManifest_AbsentFlagOverridesManifestCluster-cluster X=@absent overrides a manifest-declared X.
  • TestValidate_ClusterSet_AbsentOverridesMapped / MappedOverridesAbsent — the last-writer-wins invariant.

Binary end-to-end confirms one cluster "posthog" declaration resolves per env: validated under -env local (data composed), satisfied as absent under -env prod-us (data absent). Full suite green; go vet + gofmt clean.

A cluster block whose member roles have no composition in the selected -env unioned to zero databases but was still cs.Add'ed, registering an empty-but-mapped cluster. Resolution checks mapped before absent, so proxies into it failed with a false 'not declared in that cluster's schema' instead of being treated as absent. Corollary: -cluster NAME=@absent could not override a manifest-declared cluster.

Fix: clusterSetFromRoles registers an empty-union cluster via AddAbsent (modeled elsewhere / env-varying), not Add; and ClusterSet.Add/AddAbsent/AddAlias clear the other categories so a name is in exactly one and the latest writer wins (so -cluster NAME=@absent reliably overrides a manifest cluster).

Closes #127.
@orian orian merged commit 0409212 into main Jul 8, 2026
17 checks passed
@orian orian deleted the fix/127-uncomposed-cluster-absent branch July 8, 2026 14:03
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.

validate -manifest: a cluster with no composing member roles should resolve @absent, not empty-mapped

1 participant