Giter VIP home page Giter VIP logo

Comments (5)

davidmrdavid avatar davidmrdavid commented on September 23, 2024 1

@mj-nico23 , there's a solution in progress here: #115

Note that I had to change your implementation slightly.

from azure-functions-durable-python.

davidmrdavid avatar davidmrdavid commented on September 23, 2024

Hi @mj-nico23, thank you for reaching out!! ⚡ ⚡

Do you mind sharing the code you used for implementing the Singleton? It would help us reproduce your error with ease. In the meantime, I'll look at the exception logic and see if it makes sense to raise this error.

from azure-functions-durable-python.

mj-nico23 avatar mj-nico23 commented on September 23, 2024

Thanks for your reply @davidmrdavid.
I updated the first message with my singleton implementation.

from azure-functions-durable-python.

davidmrdavid avatar davidmrdavid commented on September 23, 2024

Bingo! I was able to reproduce this, @mj-nico23 . So this is actually a two part problem. I'll describe it below, as I think it's probably helpful to peek into the internals 😄

The first problem is that, when returning an empty body, our server isn't returning a JSON-formatted response, so the following method will fail error out:

https://github.com/Azure/azure-functions-durable-python/blob/dev/azure/durable_functions/models/utils/http_utils.py#L45

That's where you see the exception Attempt to decode JSON with unexpected mimetype. The fix is simple, we just have to tell aiohttp not to expect a JSON, so the method looks like this now:

    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            data = await response.json(content_type=None)
            if data == None:
                data = ""
            return [response.status, data]

In the snippet above, if we receive a None as our data, we know the response body was empty. If detect an empty body, we return the empty string since that's JSON-compatible. In your example, response.status will correspond to 404, as expected.

Here comes the second problem. So now we return to the following method:
https://github.com/Azure/azure-functions-durable-python/blob/dev/azure/durable_functions/models/DurableOrchestrationClient.py#L206

which is where we're supposed to handle error codes, but we aren't doing that yet as you see by that None-filled switch statement. That's because this project is still in early stages, and not quite in a public preview stage yet. So the next step is to figure out what the right message is for the 404 error statement. I'll think about it and most likely submit a PR tomorrow to fix it.

Thank you so much for raising this issue. I'll look into fixing this tomorrow morning, PDT-time. In the meantime, if you find yourself interested in trying to implement the solution by yourself, I want to encourage you to do so and submit a PR! We're always excited to see community engagement, especially so early on. Regardless, I'll submit one at some point tomorrow morning in case you're not interested in that 😄 . Thanks again! ⚡ ⚡

Update:
Hmm, even after those changes, and in order to get your example working, perhaps we'll need to implement one more step, where we watch that exception in the get_status method and return False if the 404 exception is caught...or something like that. We'll have to think about it.

from azure-functions-durable-python.

davidmrdavid avatar davidmrdavid commented on September 23, 2024

This was already merged, so I'll be closing this. Thank you for reporting it :)

from azure-functions-durable-python.

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.