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

Trailing slash in NOMAD_ADDR leads to failing API requests after redirect #126

Open
ercpe opened this issue Nov 17, 2021 · 0 comments
Open

Comments

@ercpe
Copy link

ercpe commented Nov 17, 2021

A trailing slash in the NOMAD_ADDR environment variable may lead to failing API requests with the message

nomad.api.exceptions.BaseNomadException: The BaseNomadException was raised with following response: Invalid method.

This happend to us using the nomad.api.jobs.Jobs.parse method with makes a call to the parse endpoint (https://www.nomadproject.io/api/jobs#parse-job) via POST. If the NOMAD_ADDR ends with a slash, the server first issues a 301 redirect and the following request would downgrade to GET and thus fail.

While the proper fix would be for the Nomad API to issue a 307 instead of a 301 (which retains method and body), the python-nomad library can easily account for that mistake by automatically stripping a trailing slash (e.g. with (os.getenv('NOMAD_ADDR', '').rstrip('/') or None in nomad.Nomad.__init__.

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

No branches or pull requests

1 participant