Skip to content
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

[PROD] Ensure Appeals always have a country associated #354

Open
batpad opened this issue Dec 14, 2023 · 7 comments
Open

[PROD] Ensure Appeals always have a country associated #354

batpad opened this issue Dec 14, 2023 · 7 comments
Assignees
Labels
status: PR in works Work in Progress (WIP) Issues type: bug Something isn't working

Comments

@batpad
Copy link
Contributor

batpad commented Dec 14, 2023

Yesterday, we had an error on production after an Appeal was ingested without having a Country attached. We need to make sure this cannot happen again.

If it is legitimate / possible that Appeals can be without a Country, then we should make sure the frontend does not fail if an Appeal is missing a Country.

However, I think in all likelihood, we just want to ensure on the backend that this cannot happen that an Appeal is created without a Country.

We should probably:

We should discuss this - if we think that we want to continue allowing Null values for country on the backend in case the country look-up fails, then we would need to rather make changes on the client to deal with null values for country.

For this particular Appeal where we had the country come in as null, we should investigate why that happened: was this information missing in the upstreeam data, or did we fail to match the country code correctly, or .. ?

cc @frozenhelium @thenav56 @szabozoltan69 @tovari

@batpad batpad added the type: bug Something isn't working label Dec 14, 2023
@samshara samshara added the status: pending triage Require attention from the maintainers to evaluate and decide how to proceed label Dec 14, 2023
@tovari
Copy link

tovari commented Dec 14, 2023

Thanks @batpad . The reason for this specific case was the missing country info in Apple where IFRC manages appeals and which feeds our incoming api data. It was a human error.
Unfortunately, I don't know what value was provided in the api.

@batpad
Copy link
Contributor Author

batpad commented Dec 14, 2023

Thanks for checking on the data @tovari ! This sounds like we should just enforce NOT NULL on the country column on the Appeals table.

@thenav56 do you know if you'd be able to look at making that change and dealing with migrations?

cc @szabozoltan69

@thenav56
Copy link
Member

We will start working on this. Basically, we will need to do this.
cc: @udaynwa @samshara

DB fix:

Looking at the production, we have something like this.

In [2]: from api.models import Appeal, AppealHistory

In [3]: Appeal.objects.filter(country__isnull=True).count()
Out[3]: 0

In [6]: AppealHistory.objects.filter(country__isnull=True).count()
Out[6]: 4

We will need to update Appeal History, then we can easily do the migration change.

Schema fix:

Currently, we have required=False for nullable field in most of the custom fields in serializers. Seems like we will need to use allow_null=True to update the schema.

@batpad
Copy link
Contributor Author

batpad commented Dec 15, 2023

🙏 Thank you @thenav56 ! Let me know if I can help on fixing those AppealHistory objects?

@szabozoltan69
Copy link
Collaborator

I've updated the correct country id-s on Staging and on Prod for the null-Country-having appealhistory records.
(On Staging there were 6, on Prod there were 4 such records, both were related to 2 appeals: for Chad and Mali.)

@szabozoltan69
Copy link
Collaborator

szabozoltan69 commented Dec 15, 2023

We will need to update Appeal History, then we can easily do the migration change.

So this action item is done :-)

@szabozoltan69
Copy link
Collaborator

@batpad @thenav56

@samshara samshara assigned samshara and frozenhelium and unassigned samshara Dec 21, 2023
@samshara samshara added status: PR in works Work in Progress (WIP) Issues and removed status: pending triage Require attention from the maintainers to evaluate and decide how to proceed labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: PR in works Work in Progress (WIP) Issues type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants