Improvement: Fail API deployment when policy resolution fails at startup
@Krishanx92 is already working on this.
Since Mar 25, 2026.
- Dominant language
- Go
- Stars
- 71
- Forks
- 111
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 110
Description
Summary
During gateway-controller startup, when policyResolver.ResolvePolicies(apiConfig) returns validation errors, the current implementation logs a warning and skips policy derivation while the API configuration remains in configStore and continues to be routable. This creates a fail-open condition where an API may be routed without proper policy enforcement.
Desired Behavior
If policy resolution fails for an API at startup, the API deployment itself should also fail. The API configuration should be removed from configStore (e.g., via configStore.Delete(apiConfig.UUID)) so that it is not routable without its derived policies.
Current Behavior
- Policy resolution errors are logged as warnings.
- The API remains in
configStoreand is routable without derived policies. - All other code paths (
api_deployment.go,llm_deployment.go,restapi/service.go,api_processor.go) treatResolvePolicieserrors as fatal and abort the operation.
Steps to Reproduce
- Configure an API with a policy that references a secret.
- Arrange for the secret resolution to fail (e.g., missing secret, decryption failure).
- Restart the gateway-controller.
- Observe that the API is still routable but without its expected policies.
Suggested Fix
In gateway/gateway-controller/cmd/controller/main.go, when validationErrors is non-empty during startup policy derivation, call configStore.Delete(apiConfig.UUID) before continue, log any delete error, and add a follow-up log entry to aid observability. This aligns startup behavior with the fail-safe posture used elsewhere in the codebase.
References
- PR: https://github.com/wso2/api-platform/pull/1438
- Review comment: https://github.com/wso2/api-platform/pull/1438#discussion_r2985560944
- Requested by: @nimsara66
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.