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

Roundtripping API data results in 400 bad request due to over-validation #7597

Open
1 task
rynowak opened this issue May 15, 2024 · 4 comments
Open
1 task
Labels
bug Something is broken or not working as expected triaged This issue has been reviewed and triaged

Comments

@rynowak
Copy link
Contributor

rynowak commented May 15, 2024

Steps to reproduce

  • Checkout this commit
  • Run rad recipe register to register a recipe (any recipe)

Observed behavior

You will see a failure like the following (from functional tests):

    cli.go:341: [rad] Failed to register the recipe "redistesttf" to the environment "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/environments/corerp-resources-recipe-env". Cause: PUT https://127.0.0.1:36145/apis/api.ucp.dev/v1alpha3/planes/radius/local/resourceGroups/kind-radius/providers/Applications.Core/environments/corerp-resources-recipe-env
    cli.go:341: [rad] --------------------------------------------------------------------------------
    cli.go:341: [rad] RESPONSE 400: 400 Bad Request
    cli.go:341: [rad] ERROR CODE: HttpRequestPayloadAPISpecValidationFailed
    cli.go:341: [rad] --------------------------------------------------------------------------------
    cli.go:341: [rad] {
    cli.go:341: [rad]   "error": {
    cli.go:341: [rad]     "code": "HttpRequestPayloadAPISpecValidationFailed",
    cli.go:341: [rad]     "message": "HTTP request payload failed validation against API specification with one or more errors. Please see details for more information.",
    cli.go:341: [rad]     "target": "applications.core/environments",
    cli.go:341: [rad]     "details": [
    cli.go:341: [rad]       {
    cli.go:341: [rad]         "code": "InvalidProperties",
    cli.go:341: [rad]         "message": "$.systemData.lastModifiedByType in body should be one of [User Application ManagedIdentity Key]"
    cli.go:341: [rad]       },
    cli.go:341: [rad]       {
    cli.go:341: [rad]         "code": "InvalidProperties",
    cli.go:341: [rad]         "message": "$.systemData.createdByType in body should be one of [User Application ManagedIdentity Key]"
    cli.go:341: [rad]       }
    cli.go:341: [rad]     ]
    cli.go:341: [rad]   }
    cli.go:341: [rad] }

Explanation:

This is a validation error coming from the API on the $.systemData property. The code in question is:

  • doing a GET to access the environment
  • updating a single property on the environment ($.properties.recipes)
  • doing a PUT to update the environment

This is getting blocked because $.systemData is invalid. But, we didn't change it!

Desired behavior

The right semantic here is that $.systemData should be valid when returned by the server (currently it's invalid due to missing fields).

$.systemData is also a readonly property. Users should not be able to modify it, and as such it's not relevant for validation.

The desired behavior for readonly properties is as follows. Readonly properties may be omitted from the request, or they may be provided, but should be "unchanged" relative to the server. I think it's reasonable for us to skip validation on Readonly property values as long as they match the correct type and structure.

Workaround

I'm updating the code to blank out the $.systemData in these codepaths. However this bug could break any API consumer. This pattern for "get -> change -> update" is a common idiom that doesn't work right now.

rad Version

Any version

Operating system

No response

Additional context

No response

Would you like to support us?

  • Yes, I would like to support you

AB#12378

@rynowak rynowak added the bug Something is broken or not working as expected label May 15, 2024
@radius-triage-bot
Copy link

👋 @rynowak Thanks for filing this bug report.

A project maintainer will review this report and get back to you soon. If you'd like immediate help troubleshooting, please visit our Discord server.

For more information on our triage process please visit our triage overview

@rynowak
Copy link
Contributor Author

rynowak commented May 15, 2024

For triage, this is a minor API behavior bug that seems to impact all APIs currently. Non-blocking for now, but shouldn't get dropped.

@rynowak
Copy link
Contributor Author

rynowak commented May 15, 2024

When this is fixed, there are workarounds we can remove to validate the fix. Search for the issue number in the code.

@willtsai willtsai added the triaged This issue has been reviewed and triaged label May 16, 2024
@radius-triage-bot
Copy link

👍 We've reviewed this issue and have agreed to add it to our backlog. Please subscribe to this issue for notifications, we'll provide updates when we pick it up.

We also welcome community contributions! If you would like to pick this item up sooner and submit a pull request, please visit our contribution guidelines and assign this to yourself by commenting "/assign" on this issue.

For more information on our triage process please visit our triage overview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken or not working as expected triaged This issue has been reviewed and triaged
Projects
None yet
Development

No branches or pull requests

2 participants