Coder Social home page Coder Social logo

Comments (9)

davisagli avatar davisagli commented on July 19, 2024

Note: This only happens when id is included in the POST, not when it is being created automatically from the title.

I don't think we have consensus on whether it is better to throw an error or normalize the id if the client explicitly requested an id that is not available. It might depend on the use case. There's some related discussion in #1487.

from plone.restapi.

ksuess avatar ksuess commented on July 19, 2024

@davisagli In general, no id should be provided at all. Generating an id is the job of the backend.
By now I do not see another solution, than explicitly providing an id to solve issue plone/volto#4486

from plone.restapi.

davisagli avatar davisagli commented on July 19, 2024

In the long run I think a better solution for that issue would be to give frontend routes a path like /:register that cannot collide with content ids. It's a complicated topic. Some names are reserved because they have a special use on the frontend and some are reserved because they have a special use on the backend.

from plone.restapi.

davisagli avatar davisagli commented on July 19, 2024

My own opinion: I think it is best by default for the API to throw an error if the client specifies an id and it is not available exactly as specified. Then the situation is clear. But, I would support adding an option (header or querystring) to tell the API to normalize the id and choose a different one if needed, instead of throwing an error. Then the client has a way to opt in to that if it doesn't care about getting a precise id.

from plone.restapi.

ksuess avatar ksuess commented on July 19, 2024

Great input.
Me personnally, for the moment, would opt for your suggestion to prevent name clashes at all by
"give frontend routes a path like /:register that cannot collide with content ids."

from plone.restapi.

davisagli avatar davisagli commented on July 19, 2024

The problem with my suggestion is that it's not backwards-compatible. So that's why I said "in the long run". But it could happen for Volto 17, now, if the @plone/volto-team is okay with it. Not sure if I'm stirring up some longstanding bikeshed debate...

from plone.restapi.

BhuvaneshPatil avatar BhuvaneshPatil commented on July 19, 2024

In the long run I think a better solution for that issue would be to give frontend routes a path like /:register that cannot collide with content ids. It's a complicated topic. Some names are reserved because they have a special use on the frontend and some are reserved because they have a special use on the backend.

This is great idea but it has some limitations -
For route like - /:register, we consider register as path param.
example -
'/controlpanel/rules/:id/configure'
in this path id is parameter.

from plone.restapi.

davisagli avatar davisagli commented on July 19, 2024

No, I don't mean a variable parameter, I mean the literal string /:register

from plone.restapi.

BhuvaneshPatil avatar BhuvaneshPatil commented on July 19, 2024

Another suggestion for this is,
we can add extra property in POST request, that will decide the behavior of id creation ( object creation ).

It can have two values (of course names can be changed) -

  • "GEN_ID_FORCEFULLY"
  • "GEN_ID_SIMPLE"

second value will be default value.
first one will be sent when the generated id will be in routes that clashes with default paths in volto application.
For example - register

This value will tell backend that it should consider that id generated by default is duplicate, and generate it again.

This may be not so robust implementation for the use case, various factor can be taken into consideration.

Please share your thought on the same.

from plone.restapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.