Giter Site home page Giter Site logo

Comments (5)

ikyriak avatar ikyriak commented on September 13, 2024 1

Hello @MohamadTahir
Thanks for taking the time to report this issue and the workaround! 👍 🙏

from idempotentapi.

MohamadTahir avatar MohamadTahir commented on September 13, 2024 1

Always welcome @ikyriak

there is another thing, after doing some search I realized that unsuccessful responses should not be cached when implementing idempotency, why? what if a transient error occurred? the user should be able to process the same quest with the same idempotency key, this package behaves correctly when the error occurs before reaching the controller, what do I mean by this?

so let's say that we have a request model like the following

public record SampleModel
{
    [MinLength(3)]
    public int[]  { get; set; } = Array.Empty<int>();
}

if the user sends a request and the array size is 2, then the request won't go inside the controller and will return 400, in this case, the package won't cache the response, which is the correct behavior.

but what if the user sent an array of size 4, there will be no validation errors and the request will go into the controller, in there we do our own validation on the data that has been provided in the array then decide that we need to return the NotAcceptableResult response for whatever reason, in this case, since the request is returned from within the controller it will be cached by the package, which is not the behavior that we look for.

from idempotentapi.

ikyriak avatar ikyriak commented on September 13, 2024 1

Hello @MohamadTahir

The issue of the NotAcceptedObjectResult will be fixed in the following major release, as you have provided a workaround for the moment.

Regarding the "unsuccessful responses should not be cached":

In the 1.0.2-prerelease-01 version, you can set the CacheOnlySuccessResponses attribute option to true/false. Currently, the default is false not to change the current behavior. However, the default value will be true in the following major release. You can see more details in issue #37.

Is this behavior working for your case?

from idempotentapi.

MohamadTahir avatar MohamadTahir commented on September 13, 2024 1

Perfect, that's what we want, we want to cache only successfully responses

from idempotentapi.

ikyriak avatar ikyriak commented on September 13, 2024 1

Hello @MohamadTahir,

The fix for the NotAcceptedObjectResul issue has been released in v2.0.0-RC.01 🎆 🎉 . Could you please verify that it's OK?

from idempotentapi.

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.