-
Notifications
You must be signed in to change notification settings - Fork 516
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
FastAPI file upload not working with sentry after 1.9.6 #1595
Comments
@dearkafka, we released 1.9.7, https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md#197. You can give it a try and it may result in a success for you. |
with version 1.9.8 still got the error. |
Thanks @RockBomber! We identified this a few days ago too. It's on our backlog and the team will be on it soon. |
We managed to work around this problem for now by adding |
Hey @dearkafka ! I have now created you sample project like this: (note that I have NOT specified the integrations, because they are now detected automatically!) I have then uploaded an image with Could you please retry with the newest SDK version and tell me if it still does not work? Thanks! |
@antonpirker unfortunately I cannot say it worked( my sample: from fastapi import FastAPI, File, UploadFile
from PIL import Image
import uvicorn
import io
import sentry_sdk
sentry_sdk.init(
dsn=SECRET,
traces_sample_rate=1.0,
)
app = FastAPI()
@app.post("/predict")
async def predict(file: UploadFile = File(default=None)):
contents = await file.read()
Image.open(io.BytesIO(contents)).convert("RGB")
return {"result": "ok"}
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=8888, loop="asyncio", lifespan="on") and with this a I have an error But if I add I have installed packages: Python 3.10.6 |
Hey @RockBomber ! Sorry, I can not reproduce this. I did everything exactly like you did, but for me it works: Can you please add |
output with debug:
|
Hello! Thanks for the debug output! Could it be that you upload a file that is not an image? |
It's because "image" has zero bytes :) |
Can you send me the image to [email protected] so I can test? |
You know, it's interesting.. with first random image I've got that error but with other images I don't have the error. Some "magic" image.. I'll send it to you |
Thanks for the image. Yes, it is strange. We will do a release soon, then you can try again if it is finally working. |
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.9.6
Steps to Reproduce
Expected Result
{"result": "ok"}
Actual Result
so, when disabling sentry - all works fine, when adding sentry - it breaks. apparently sentry messes up content of uploaded file.
The text was updated successfully, but these errors were encountered: