-
Notifications
You must be signed in to change notification settings - Fork 293
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
ABDM: Log the errors instead of sending them as a response #1821
Conversation
@ProCode2 can you handle this issue (ohcnetwork/care_fe#7000 (comment)) also in this pr. To replicate the issue, In the front end,
That will trigger the error you see in the comment mentioned. Have a conditional check if the Abha number already exists before creating the Abha number, and return a response with a neat error message. |
@khavinshankar This creates a ABHA object if not exists and then adds ABHA details to patient. Since Do I understand this correctly? def confirm_with_mobile_otp(self, request):
data = request.data
if ratelimit(request, "confirm_with_mobile_otp", [data["txnId"]]):
raise CaptchaRequiredException(
detail={"status": 429, "detail": "Too Many Requests Provide Captcha"},
code=status.HTTP_429_TOO_MANY_REQUESTS,
)
serializer = VerifyOtpRequestPayloadSerializer(data=data)
serializer.is_valid(raise_exception=True)
response = HealthIdGateway().confirm_with_mobile_otp(data)
abha_profile = HealthIdGateway().get_profile(response)
# have a serializer to verify data of abha_profile
abha_object = self.create_abha(
abha_profile,
{
"access_token": response["token"],
"refresh_token": response["refreshToken"],
"txn_id": data["txnId"],
},
)
if "patientId" in data:
patient_id = data.pop("patientId")
allowed_patients = get_patient_queryset(request.user)
patient_obj = allowed_patients.filter(external_id=patient_id).first()
if not patient_obj:
raise ValidationError({"patient": "Not Found"})
if not self.add_abha_details_to_patient(
abha_object,
patient_obj,
):
return Response(
{"message": "Failed to add abha Number to the patient"},
status=status.HTTP_400_BAD_REQUEST,
)
return Response(
{"id": abha_object.external_id, "abha_profile": abha_profile},
status=status.HTTP_200_OK,
) |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1821 +/- ##
==========================================
- Coverage 61.62% 61.60% -0.02%
==========================================
Files 212 212
Lines 11664 11674 +10
Branches 1655 1655
==========================================
+ Hits 7188 7192 +4
- Misses 4180 4186 +6
Partials 296 296 ☔ View full report in Codecov by Sentry. |
Proposed Changes
Associated Issue
Merge Checklist
/docs
Only PR's with test cases included and passing lint and test pipelines will be reviewed
@coronasafe/care-backend-maintainers @coronasafe/care-backend-admins