Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate backend host count on config init #744

Closed
wants to merge 2 commits into from
Closed

Conversation

thedae
Copy link
Member

@thedae thedae commented Dec 17, 2024

Fixes krakend/krakend-ce#948

Config initialization fails if there's an endpoint without any backend hosts

Example

Config file

{
  "$schema": "https://www.krakend.io/schema/krakend.json",
  "version": 3,
  "echo_endpoint": true,
  "endpoints": [
    {
      "endpoint": "/some-api",
      "backend": [
        {
          "url_pattern": "/__echo",
          "host": [
            "http://localhost:8080"
          ]
        }
      ]
    },
    {
      "endpoint": "/api-without-backend",
      "backend": [
        {
          "url_pattern": "/__echo",
          "host": []
        }
      ]
    }
  ]
}

Config check

$ krakend check -c ./krakend.json 
Parsing configuration file: /home/dae/work/krakend/configs/ce-issue-948/krakend.json
ERROR parsing the configuration file:	'/home/dae/work/krakend/configs/ce-issue-948/krakend.json': can't register 'GET /api-without-backend' endpoint, it doesn't have any host

exit status 1

Startup

$ krakend run -c ./krakend.json 
ERROR parsing the configuration file: '/home/dae/work/krakend/configs/ce-issue-948/krakend.json': can't register 'GET /api-without-backend' endpoint, it doesn't have any host
exit status 255

@taik0
Copy link
Contributor

taik0 commented Jan 8, 2025

This has been addressed in the schema and the check command of KrakenD. We will maintain the current behavior.

@taik0 taik0 closed this Jan 8, 2025
@thedae thedae deleted the validate_hosts branch January 9, 2025 08:37
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.

An empty host is not detected by validation
2 participants