Skip to content

Commit

Permalink
[Justice Counts] Replace INVALID_CHILD_AGENCY error with UNEXPECTED_E…
Browse files Browse the repository at this point in the history
…RROR (Recidiviz/recidiviz-data#29387)

## Description of the change

Replace INVALID_CHILD_AGENCY error with UNEXPECTED_ERROR.

The codebase is configured right now to send a INVALID_CHILD_AGENCY
error when we experience an error that we don't know how to handle.

This INVALID_CHILD_AGENCY is misleading, and it seems like it's an
accident where it is. Let's replace it with a more straightforward
UNEXPECTED_ERROR error. This is an improvement because it tells us more
directly that we are not handling the error properly - instead of
leading us down the wrong path by suggesting something is up with our
child agency logic.

## Testing
I tested this locally and got the unexpected error message below.

<img width="967" alt="Screenshot 2024-04-26 at 10 17 28 AM"
src="https://github.com/Recidiviz/recidiviz-data/assets/130382407/f428a24b-fb79-48b3-8aaf-af7235aadda7">

Zenhub Ticket Recidiviz/recidiviz-data#29303

GitOrigin-RevId: 10ac0975afe116189831f9129b4ef98a4f775703
  • Loading branch information
brandon-hills authored and Helper Bot committed May 11, 2024
1 parent b363f47 commit 281ebab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions recidiviz/justice_counts/bulk_upload/spreadsheet_uploader.py
Expand Up @@ -43,7 +43,11 @@
from recidiviz.justice_counts.metrics.metric_interface import MetricInterface
from recidiviz.justice_counts.report import ReportInterface
from recidiviz.justice_counts.types import DatapointJson
from recidiviz.justice_counts.utils.constants import INVALID_CHILD_AGENCY, UploadMethod
from recidiviz.justice_counts.utils.constants import (
INVALID_CHILD_AGENCY,
UNEXPECTED_ERROR,
UploadMethod,
)
from recidiviz.persistence.database.schema.justice_counts import schema
from recidiviz.persistence.database.schema.justice_counts.schema import (
ReportingFrequency,
Expand Down Expand Up @@ -875,7 +879,7 @@ def _handle_error(
description=(
e.message # type: ignore[attr-defined]
if hasattr(e, "message")
else INVALID_CHILD_AGENCY
else UNEXPECTED_ERROR
),
)
e.sheet_name = sheet_name
Expand Down
2 changes: 2 additions & 0 deletions recidiviz/justice_counts/utils/constants.py
Expand Up @@ -26,6 +26,8 @@

INVALID_CHILD_AGENCY = "INVALID_CHILD_AGENCY"

UNEXPECTED_ERROR = "UNEXPECTED_ERROR"

AUTOMATIC_UPLOAD_ID = -1

# Unsubscribe group ID number for SendGrid for Justice Counts
Expand Down

0 comments on commit 281ebab

Please sign in to comment.