Skip to content

Validate endpoint connection info without saving it first - #536

Open
mihaelabalutoiu wants to merge 3 commits into
cloudbase:mainfrom
mihaelabalutoiu:fix-endpoint-validate-and-save
Open

mihaelabalutoiu wants to merge 3 commits into
cloudbase:mainfrom
mihaelabalutoiu:fix-endpoint-validate-and-save

Conversation

@mihaelabalutoiu

@mihaelabalutoiu mihaelabalutoiu commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Previously, the endpoint validation API only worked on stored endpoints (/endpoints/{id}/actions), so we had to save an endpoint before we could check its connection info. Invalid endpoints were persisted when validation failed.

This PR implements the following:

  • Support validation bodies in key error messages:
    • allow format_keyerror_message to describe missing attributes of a validation request body.
  • Add an endpoint action to validate connection info:
    • add a validate-connection-info action on /endpoints/actions, which validates the platform and connection_info given in the request body, so an endpoint can be checked before it is saved.
  • Updates the API reference, the policy docs and the unit tests.

Related PRs: coriolis-web python-coriolisclient

@mihaelabalutoiu
mihaelabalutoiu force-pushed the fix-endpoint-validate-and-save branch from a4ab0a4 to 2626c4b Compare October 1, 2026 09:47
@mihaelabalutoiu

mihaelabalutoiu commented Oct 1, 2026 •

Copy link
Copy Markdown
Member Author

Note: The integration tests fail with:

TypeError: EndpointManager.validate_connection() takes 2 positional arguments but 3 were given

This is expected: the integration tests install python-coriolisclient from its main branch, which still has the old validate_connection(endpoint) signature.
The CLI PR needs to be merged first, then the integration tests can be re-run.

Update: no longer applies — the integration tests call the new action directly over REST, so they don't depend on the client and this PR stands on its own.

Comment thread coriolis/api/v1/router.py

endpoint_actions_resource = endpoint_actions.create_resource()
self.resources['endpoint_actions'] = endpoint_actions_resource
endpoint_path = '/{project_id}/endpoints/{id}'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this API? We can add a new one that validates the connection info, while still allowing an existing endpoint to be validated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right — I've added validate-connection-info as a new action on POST /endpoints/actions, and left validate-connection unchanged. Thank you!

Allow `format_keyerror_message` to describe missing attributes of a
validation request body.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
@mihaelabalutoiu
mihaelabalutoiu marked this pull request as draft October 12, 2026 09:33
@mihaelabalutoiu
mihaelabalutoiu force-pushed the fix-endpoint-validate-and-save branch 2 times, most recently from 33bd47d to f66d65a Compare October 12, 2026 10:58
Add a `validate-connection-info` action on `/endpoints/actions`, which
validates the platform and connection info given in the request body, so
an endpoint can be checked before it is saved.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
@mihaelabalutoiu
mihaelabalutoiu force-pushed the fix-endpoint-validate-and-save branch from f66d65a to 94937cb Compare October 12, 2026 12:17
@mihaelabalutoiu
mihaelabalutoiu marked this pull request as ready for review October 13, 2026 10:27
def _validate_connection_info(self, req, body):
context = req.environ['coriolis.context']
context.can(
"%s:validate_connection_info" % (endpoint_policies.ENDPOINTS_POLICY_PREFIX)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
result = self.endpoints_api.validate_connection_info(**args)
(
self.endpoints_api._rpc_conductor_client.validate_endpoint_connection_info.assert_called_once_with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Why is this line inside of paranthesis?

)(*(args.values()))
self.assertEqual(
(
self.endpoints_api._rpc_conductor_client.validate_endpoint_connection_info.return_value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

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.

3 participants