Skip to content

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

Description

@ercpe

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__.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions