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

Validate IncidentUpdate's incident_type field against the retrieved incident type. #4699

Merged

Conversation

metroid-samus
Copy link
Contributor

The IncidentUpdate's incident_type field is an IncidentTypeBase, which does not have an id field. Thus, the initial id comparison resulted in an error.

However, earlier in the incident_service.update() function call, the incident_type is already retrieved. We can perform the comparisons against this object's id.

@metroid-samus metroid-samus added the bug Something isn't working label May 7, 2024
@metroid-samus metroid-samus requested a review from wssheldon May 7, 2024 16:43
@metroid-samus metroid-samus self-assigned this May 7, 2024
@metroid-samus metroid-samus marked this pull request as ready for review May 7, 2024 16:46
@wssheldon
Copy link
Contributor

I believe the error occurs on incident_in as well:

  File "/Users/wshel/Projects/dispatch/src/dispatch/incident/service.py", line 369, in update
    if incident_in.incident_type.id != incident_type.id:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'IncidentTypeBase' object has no attribute 'id'

@wssheldon
Copy link
Contributor

I believe the error occurs on incident_in as well:

  File "/Users/wshel/Projects/dispatch/src/dispatch/incident/service.py", line 369, in update
    if incident_in.incident_type.id != incident_type.id:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'IncidentTypeBase' object has no attribute 'id'

This works for me locally:

    # Update total incident reponse cost if incident type has changed.
    if incident_type.id != incident.incident_type.id:
        incident_cost_service.update_incident_response_cost(
            incident_id=incident.id, db_session=db_session
        )

@metroid-samus metroid-samus merged commit 0993a9b into master May 7, 2024
8 checks passed
@metroid-samus metroid-samus deleted the bugfix/validate-against-retrieved-incident-type branch May 7, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants