-
Notifications
You must be signed in to change notification settings - Fork 22
Dev.ej/partial xml in 422 assemble #292
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
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #292 +/- ##
=======================================
Coverage 88.59% 88.59%
=======================================
Files 22 22
Lines 1885 1885
Branches 309 309
=======================================
Hits 1670 1670
Misses 178 178
Partials 37 37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
roedoejet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @joanise
| else: | ||
| logs = "Logs: " + captured_logs.getvalue() | ||
| raise HTTPException( | ||
| return JSONResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer the explicitness of HTTPException it should work also, since HTTPException.detail accepts any type:
raise HTTPException(status_code=422, detail={
"detail": "g2p could not be performed, please check your text or your language code. " + logs,
"g2p_error_words": non_convertible_words,
"partial_ras": xml_to_string(g2ped),
})But introduces a breaking change for Studio-Web, since the detail key with the error message is one level deeper in the response:
const resp = await fetch(...);
if(resp.status_code===422) {
const exception = await resp.json();
const contentLog = exception["detail"]["detail"];
const g2pBadWords = exception["detail"]["g2p_error_words"];
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. It's good to know for future similar cases, but backwards compatibility is important here to allow updating the back end and the front end each on their own schedule, so I'll keep the JSONResponse with a status code.
sergeleger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
PR Goal?
enable ReadAlongs/Studio-Web#463 in a better way: instead of hacking the full partial message into the exception message, return a JSONResponse with code 422, the usual detail field, and added fields for Studio-Web to handle if it wants.
Fixes?
one step along the path to better display g2p errors in S-Web
Also, I added spaces inside the quotes for the problem words, so we'll see
' ̓ 'instead of' ̓'(desired change) and' 234 'instead of'234'(neutral change).Note that I did not make the changes optional, since extra fields in the 422 response are currently ignored by Studio-Web.
Feedback sought?
Priority?
normal
Tests added?
not yet, I have to think about how to do that.The code is covered by existing tests
but I will look forand I added explicit relevant assertionsHow to test?
In Studio:
diacritics ̓ are 123 foo : barinto the"input"part of the requestdetaillike in the production code, plusg2p_error_wordswith an array of unprocessable words andpartial_raswith the RAS XML processed as far as it could be processed.Contrast with doing the same on https://readalong-studio.herokuapp.com/api/v1/docs#/default/assemble_assemble_post where you will get only
detailand no space inside the quoted g2p error words.With the web API still running, go to Studio-Web and run:
diacritics ̓ are 123 foo : barin the text boxg2p_error_wordsandpartial_rasin there, which the Studio-Web app will ignore (until Del changes that).Confidence?
Medium
Version change?
no