[Bug]: Updating a REST API on the gateway doesn't resolve its vhosts, so _gateway_default_ is stored as a hostname
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read gateway/gateway-controller/pkg/service/restapi/service.go, especially RestAPIService.Update and the create path through DeployAPIConfiguration; compare how each handles vhosts. Then inspect gateway/gateway-controller/pkg/utils/api_deployment.go and its resolveVhostSentinels function. Done means updates resolve _gateway_default_ and missing vhosts to the current gateway defaults and GET returns the resolved values; check for existing REST API update tests to confirm this behavior.
Written by the indexing model from the issue text.
Description
Please select the area the issue is related to
Gateway
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Description
When a REST API is created on the gateway, its vhosts are resolved at deploy time: _gateway_default_, or a missing vhosts block, becomes the gateway's current default hosts. The resolved values are stored, so a later change to the gateway defaults doesn't move the API (discussion #369).
Updating the API through the gateway's REST API (PUT /rest-apis/{id}) skips that step:
- With
vhosts.main: _gateway_default_: the placeholder is stored literally, as a hostname. The API stops answering on the default hosts. - With no
vhostsblock: nothing is stored. The API keeps answering on the defaults only because the router falls back to the live default. So it follows the next config change, which is what deploy-time resolution is meant to prevent, andGETshows no vhosts.
Observed (gateway with router.vhosts.main.default = "*.wso2.com" and router.vhosts.sandbox.default = "*-sandbox.wso2.com")
POST /rest-apiswith novhosts:GET /rest-apis/{id}showsspec.vhosts.main*.wso2.comandspec.vhosts.sandbox*-sandbox.wso2.com, and a request withHost: api.wso2.comanswers 200.PUT /rest-apis/{id}withvhosts: {"main": "_gateway_default_"}:GETshowsspec.vhosts.main_gateway_default_, and the same request now answers 404.PUT /rest-apis/{id}with novhosts:GETshows nospec.vhostsat all.
Expected
An update resolves vhosts the same way a create does. _gateway_default_ and a missing vhosts block become the current gateway defaults, which are stored and shown by GET.
Cause
Create goes through DeployAPIConfiguration (gateway/gateway-controller/pkg/service/restapi/service.go:174), which calls resolveVhostSentinels (gateway/gateway-controller/pkg/utils/api_deployment.go:312). RestAPIService.Update (pkg/service/restapi/service.go:320) parses the body and saves it without that call. The event gateway's WebSub update does resolve vhosts, because it goes through DeployAPIConfiguration.
Steps to Reproduce
- Start a gateway with
[router.vhosts.main] default = "*.wso2.com". - Create a REST API with no
vhoststhroughPOST /rest-apis. A request withHost: api.wso2.comanswers 200. - Update it through
PUT /rest-apis/{id}with"vhosts": {"main": "_gateway_default_"}. GET /rest-apis/{id}shows_gateway_default_, and the request withHost: api.wso2.comanswers 404.- Update it again with no
vhosts:GETshows no vhosts.
Severity Level of the Issue
Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)
Environment Details (with versions)
Current main (e90cde473). Platform-api and gateway built from source and run by the IT suite (tests/framework), on macOS with Rancher Desktop.
- Dominant language
- Go
- Stars
- 85
- Forks
- 137
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 247
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
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.
More from wso2/api-platform
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
wso2/api-platform#4369 ·
Maintainers usually reply within 1 day
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsOpenArea/Policies Aspect/Other Severity/Trivial Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
wso2/api-platform#4355 ·
Maintainers usually reply within 1 day
-
Area/Gateway Aspect/API Severity/Minor Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wso2/api-platform#4348 ·
Maintainers usually reply within 1 day
-
Aspect/AI Aspect/API. Severity/Major
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
wso2/api-platform#4343 ·
Maintainers usually reply within 1 day
-
Area/Policies Aspect/Configuration Severity/Minor Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
wso2/api-platform#4330 ·
Maintainers usually reply within 1 day
All issues in wso2/api-platform
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Inconsistency between golang and cue in specPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
security
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Tencent/LoopForge#1087 · 1 comment ·
Maintainers usually reply within 1 day