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

[Bug][Data loss]: if passing an invalid asset.id, fullpath to object mutation GraphQL query, the assets are silently discarded #823

Closed
dkarlovi opened this issue Dec 6, 2023 · 3 comments · Fixed by #825
Assignees
Milestone

Comments

@dkarlovi
Copy link

dkarlovi commented Dec 6, 2023

Expected behavior

Error reported before any mutation is done. Same thing happens with unknown IDs, it just ignores them.

Actual behavior

Any unknown assets silently discarded.

Steps to reproduce

  1. create class Product with input SKU and many to one assets called Images
  2. add an object 123 with a few images
  3. run this (see [Bug]: fetching asset.fullpath will include frontend_prefixes.source #822 why the path contains a hostname):
mutation {
  updateProduct(
    id: 123
    input: {
      SKU: "ABC"
      Images: [
        {
          fullpath: "https://example.com/Brands/loxeal_logo.png"
          type: "asset"
        }
      ]
    }
  ) {
    output {
      id
    }
    message
    success
  }
}
  1. it responds with success and the SKU is correctly persisted, but images are empty (and any previous images are deleted)
@dkarlovi dkarlovi added the Bug label Dec 6, 2023
@dkarlovi dkarlovi changed the title [Bug]: if passing an invalid asset.fullpath to object mutation GraphQL query, the assets are silently discarded [Bug][Data loss]: if passing an invalid asset.fullpath to object mutation GraphQL query, the assets are silently discarded Dec 6, 2023
@dkarlovi dkarlovi changed the title [Bug][Data loss]: if passing an invalid asset.fullpath to object mutation GraphQL query, the assets are silently discarded [Bug][Data loss]: if passing an invalid asset.id, fullpath to object mutation GraphQL query, the assets are silently discarded Dec 6, 2023
@dkarlovi
Copy link
Author

dkarlovi commented Dec 6, 2023

It seems this applies to any relation, not just assets, including one to one. If you pass gibberish to it, it ignores it and just stores null, but it should actually validate the proposed changes before saving.

@kingjia90
Copy link
Contributor

@dkarlovi Please have a look and try out if #825 resolves the described problem
Thank you in advance

@kingjia90
Copy link
Contributor

Fixed by #825

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