Filter Mismatch
Source: hello-pepr-ns-wrong
When a Capability defines specific namespaces, actions cannot use .InNamespace() with namespaces outside that list. The action will never trigger because the namespace filter references a namespace the Capability is not bound to.
This example demonstrates what not to do. When using .InNamespace() with bounded namespaces:
- Always verify the namespace in your
.InNamespace()filter exists in the Capability’s namespace list - Double-check your Capability’s
namespacesarray includes all namespaces you’re filtering for - Use
namespaces: []if you need to operate across all cluster namespaces - Use this pattern as a debugging reference when actions aren’t triggering as expected
Always ensure .InNamespace() filters reference namespaces that are either in the Capability’s namespace list or use namespaces: [] to allow all namespaces.
Code Example
Section titled “Code Example”View full example on Github
Capability Bound to Specific Namespace
Section titled “Capability Bound to Specific Namespace”export const HelloPeprNamespace = new Capability({ name: "hello-pepr-namespace", description: "hello-pepr-namespace", namespaces: ["hello-pepr-namespace"],});Action Using Wrong Namespace
Section titled “Action Using Wrong Namespace”When(a.ConfigMap) .IsCreated() .InNamespace("wrong") .Validate(async function validateWrong(request) { return request.Approve(); });This action will never trigger because:
Section titled “This action will never trigger because:”- The Capability is bound to
["hello-pepr-namespace"] - The action tries to filter for namespace
"wrong" - Since
"wrong"is not in the Capability’s namespace list, this action can never process any resources