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

Local api update api can't update block with localized #3189

Closed
cmngan opened this issue Aug 16, 2023 · 5 comments
Closed

Local api update api can't update block with localized #3189

cmngan opened this issue Aug 16, 2023 · 5 comments
Assignees
Labels
status: cant-reproduce If an issue cannot be reproduced

Comments

@cmngan
Copy link

cmngan commented Aug 16, 2023

Link to reproduction

https://github.com/cmngan/payload-cms-local-api-update-error

To Reproduce

  1. Use local api, e.g. in a collection, add endpoints
image
  1. Inside endpoint, use local api as
handler: async (req, res, next) => {
    const item = {} // `{}` is a placeholder, real data see step 3
    req.payload.update({
        collection: 'some com',
        data: item,
        locale: "all",
        id: item.id,
      })
    )
}
  1. item is like below(simplified)
	{
		"id": "sample",
		"adminTitle": "Example",
		"template_modules_v3": [
			{
				"selectedSites": ["en-kr", "en-gl"],
				"title": {
					"en-gl": "eeeeeeeeeeee"
				},
				"id": "16709298540833613392",
				"blockType": "overview"
			}
		],
		"city": "sydney",
		"author": "638d5ab62d091072b2142a1a",
		"_status": "published"
	}
  1. Call the endpoint
  2. Some data can be updated, e.g. adminTitle, template_modules_v3 -> selectedSites
  3. Some data can NOT be updated, e.g. template_modules_v3 -> title -> en-gl
  4. If block id(16709298540833613392) is changed to something else, title can be updated as well.

Describe the Bug

See above To Reproduce. Seems like it is a bug inside block with localized is true.
Since selectedSites is working, I guess localized is related.

Payload Version

1.13.4

@cmngan cmngan added the status: needs-triage Possible bug which hasn't been reproduced yet label Aug 16, 2023
@AlessioGr AlessioGr added status: needs-repro If an issue does not include a reproduction and removed status: needs-triage Possible bug which hasn't been reproduced yet labels Aug 18, 2023
@cmngan
Copy link
Author

cmngan commented Aug 21, 2023

@AlessioGr
Added repo for reproducing the bug
https://github.com/cmngan/payload-cms-local-api-update-error

@AlessioGr AlessioGr self-assigned this Aug 21, 2023
@AlessioGr AlessioGr added status: verified If an issue has been reproduced and removed status: needs-repro If an issue does not include a reproduction labels Aug 21, 2023
@AlessioGr
Copy link
Member

AlessioGr commented Aug 21, 2023

Thank you @cmngan !

I've checked it out and, for some reason, I can reproduce that the localized field inside the array IS updated, but the top-level localized field, on the other hand, is not.

So, the exact opposite way.

Will do some more digging into this

@cmngan
Copy link
Author

cmngan commented Aug 21, 2023

Thank you @cmngan !

I've checked it out and, for some reason, I can reproduce that the localized field inside the array IS updated, but the top-level localized field, on the other hand, is not.

So, the exact opposite way.

Will do some more digging into this

Thanks @AlessioGr
Interesting finding. 👀

AlessioGr added a commit that referenced this issue Aug 22, 2023
@JarrodMFlesch JarrodMFlesch self-assigned this Sep 18, 2023
@JarrodMFlesch
Copy link
Contributor

@cmngan I believe this has been resolved in 2.0. Could you update and let me know?

@JarrodMFlesch JarrodMFlesch added status: cant-reproduce If an issue cannot be reproduced and removed status: verified If an issue has been reproduced labels Nov 1, 2023
@JarrodMFlesch
Copy link
Contributor

@cmngan I am going to close this since I was unable to repro on 2.x. Please ping us if it is still a problem for you and we can gather more details!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: cant-reproduce If an issue cannot be reproduced
Projects
None yet
Development

No branches or pull requests

3 participants