Skip to content

Commit 385b342

Browse files
authored
Merge pull request #1602 from GSA/main
03/14/2025 Production Deploy
2 parents 379913f + 32df2af commit 385b342

File tree

15 files changed

+303
-234
lines changed

15 files changed

+303
-234
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ updates:
99
directory: "/" # Location of package manifests
1010
schedule:
1111
interval: "daily"
12+
labels:
13+
- "dependabot" # Custom label to identify Dependabot PRs

app/aws/s3.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def list_s3_objects():
118118
break
119119
except Exception:
120120
current_app.logger.exception(
121-
"An error occurred while regenerating cache #notify-admin-1200",
121+
"An error occurred while regenerating cache #notify-debug-admin-1200",
122122
)
123123

124124

@@ -200,7 +200,7 @@ def read_s3_file(bucket_name, object_key, s3res):
200200

201201
except LookupError:
202202
# perhaps our key is not formatted as we expected. If so skip it.
203-
current_app.logger.exception("LookupError #notify-admin-1200")
203+
current_app.logger.exception("LookupError #notify-debug-admin-1200")
204204

205205

206206
def get_s3_files():
@@ -213,7 +213,7 @@ def get_s3_files():
213213

214214
s3res = get_s3_resource()
215215
current_app.logger.info(
216-
f"job_cache length before regen: {len_job_cache()} #notify-admin-1200"
216+
f"job_cache length before regen: {len_job_cache()} #notify-debug-admin-1200"
217217
)
218218
try:
219219
with ThreadPoolExecutor() as executor:
@@ -222,7 +222,7 @@ def get_s3_files():
222222
current_app.logger.exception("Connection pool issue")
223223

224224
current_app.logger.info(
225-
f"job_cache length after regen: {len_job_cache()} #notify-admin-1200"
225+
f"job_cache length after regen: {len_job_cache()} #notify-debug-admin-1200"
226226
)
227227

228228

@@ -290,7 +290,7 @@ def file_exists(file_location):
290290

291291
def get_job_location(service_id, job_id):
292292
current_app.logger.debug(
293-
f"#s3-partitioning NEW JOB_LOCATION: {NEW_FILE_LOCATION_STRUCTURE.format(service_id, job_id)}"
293+
f"#notify-debug-s3-partitioning NEW JOB_LOCATION: {NEW_FILE_LOCATION_STRUCTURE.format(service_id, job_id)}"
294294
)
295295
return (
296296
current_app.config["CSV_UPLOAD_BUCKET"]["bucket"],
@@ -308,7 +308,7 @@ def get_old_job_location(service_id, job_id):
308308
Remove this when everything works with the NEW_FILE_LOCATION_STRUCTURE.
309309
"""
310310
current_app.logger.debug(
311-
f"#s3-partitioning OLD JOB LOCATION: {FILE_LOCATION_STRUCTURE.format(service_id, job_id)}"
311+
f"#notify-debug-s3-partitioning OLD JOB LOCATION: {FILE_LOCATION_STRUCTURE.format(service_id, job_id)}"
312312
)
313313
return (
314314
current_app.config["CSV_UPLOAD_BUCKET"]["bucket"],
@@ -507,7 +507,7 @@ def get_personalisation_from_s3(service_id, job_id, job_row_number):
507507

508508
def get_job_metadata_from_s3(service_id, job_id):
509509
current_app.logger.debug(
510-
f"#s3-partitioning CALLING GET_JOB_METADATA with {service_id}, {job_id}"
510+
f"#notify-debug-s3-partitioning CALLING GET_JOB_METADATA with {service_id}, {job_id}"
511511
)
512512
obj = get_s3_object(*get_job_location(service_id, job_id))
513513
return obj.get()["Metadata"]

app/celery/scheduled_tasks.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,14 @@ def batch_insert_notifications(self):
325325
elif isinstance(notification_dict["created_at"], list):
326326
notification_dict["created_at"] = notification_dict["created_at"][0]
327327
notification = Notification(**notification_dict)
328-
if notification is not None:
328+
# notify-api-749 do not write to db
329+
# if we have a verify_code we know this is the authentication notification at login time
330+
# and not csv (containing PII) provided by the user, so allow verify_code to continue to exist
331+
if notification is None:
332+
continue
333+
if "verify_code" in str(notification.personalisation):
334+
pass
335+
else:
329336
batch.append(notification)
330337
try:
331338
dao_batch_insert_notifications(batch)

app/clients/pinpoint/aws_pinpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def validate_phone_number(self, country_code, phone_number):
3939
current_app.logger.info(hilite(response))
4040
except ClientError:
4141
current_app.logger.exception(
42-
"#validate-phone-number Could not validate with pinpoint"
42+
"#notify-debug-validate-phone-number Could not validate with pinpoint"
4343
)
4444

4545
# TODO This is the structure of the response. When the phone validation

app/clients/sms/aws_sns.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,16 @@ def send_sms(self, to, content, reference, sender=None, international=False):
6868
non_scrubbable = " ".join(sender)
6969

7070
self.current_app.logger.info(
71-
f"notify-api-1385 sender {non_scrubbable} is a {type(sender)} default is a {type(default_num)}"
71+
f"notify-debug-api-1385 sender {non_scrubbable} is a {type(sender)} \
72+
default is a {type(default_num)}"
7273
)
7374
else:
7475
self.current_app.logger.warning(
75-
f"notify-api-1385 sender is type {type(sender)}!! {sender}"
76+
f"notify-debug-api-1385 sender is type {type(sender)}!! {sender}"
7677
)
7778
if self._valid_sender_number(sender):
7879
self.current_app.logger.info(
79-
f"notify-api-1385 use valid sender {non_scrubbable} instead of default {default_num}"
80+
f"notify-debug-api-1385 use valid sender {non_scrubbable} instead of default {default_num}"
8081
)
8182

8283
attributes["AWS.MM.SMS.OriginationNumber"] = {
@@ -85,7 +86,7 @@ def send_sms(self, to, content, reference, sender=None, international=False):
8586
}
8687
else:
8788
self.current_app.logger.info(
88-
f"notify-api-1385 use default {default_num} instead of invalid sender"
89+
f"notify-debug-api-1385 use default {default_num} instead of invalid sender"
8990
)
9091

9192
attributes["AWS.MM.SMS.OriginationNumber"] = {

app/dao/jobs_dao.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,17 @@ def dao_create_job(job):
158158
now_time = utc_now()
159159
diff_time = now_time - orig_time
160160
current_app.logger.info(
161-
f"#notify-admin-1859 dao_create_job orig created at {orig_time} and now {now_time}"
161+
f"#notify-debug-admin-1859 dao_create_job orig created at {orig_time} and now {now_time}"
162162
)
163163
if diff_time.total_seconds() > 300: # It should be only a few seconds diff at most
164164
current_app.logger.error(
165-
"#notify-admin-1859 Something is wrong with job.created_at!"
165+
"#notify-debug-admin-1859 Something is wrong with job.created_at!"
166166
)
167167
if os.getenv("NOTIFY_ENVIRONMENT") not in ["test"]:
168168
job.created_at = now_time
169169
dao_update_job(job)
170170
current_app.logger.error(
171-
f"#notify-admin-1859 Job created_at reset to {job.created_at}"
171+
f"#notify-debug-admin-1859 Job created_at reset to {job.created_at}"
172172
)
173173

174174

app/delivery/send_to_providers.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ def send_sms_to_provider(notification):
4242
"""
4343
# Take this path for report generation, where we know
4444
# everything is in the cache.
45-
personalisation = get_personalisation_from_s3(
46-
notification.service_id,
47-
notification.job_id,
48-
notification.job_row_number,
49-
)
50-
notification.personalisation = personalisation
45+
46+
if "verify_code" not in str(notification.personalisation):
47+
personalisation = get_personalisation_from_s3(
48+
notification.service_id,
49+
notification.job_id,
50+
notification.job_row_number,
51+
)
52+
notification.personalisation = personalisation
5153

5254
service = SerialisedService.from_id(notification.service_id)
5355
message_id = None
@@ -92,7 +94,6 @@ def send_sms_to_provider(notification):
9294
recipient = None
9395
# It is our 2facode, maybe
9496
recipient = _get_verify_code(notification)
95-
9697
if recipient is None:
9798
recipient = get_phone_number_from_s3(
9899
notification.service_id,
@@ -107,7 +108,7 @@ def send_sms_to_provider(notification):
107108
sender_numbers = get_sender_numbers(notification)
108109
if notification.reply_to_text not in sender_numbers:
109110
raise ValueError(
110-
f"{notification.reply_to_text} not in {sender_numbers} #notify-admin-1701"
111+
f"{notification.reply_to_text} not in {sender_numbers} #notify-debug-admin-1701"
111112
)
112113

113114
send_sms_kwargs = {
@@ -158,7 +159,7 @@ def _experimentally_validate_phone_numbers(recipient):
158159
if recipient_lookup in current_app.config["SIMULATED_SMS_NUMBERS"] and os.getenv(
159160
"NOTIFY_ENVIRONMENT"
160161
) in ["development", "test"]:
161-
current_app.logger.info(hilite("#validate-phone-number fired"))
162+
current_app.logger.info(hilite("#notify-debug-validate-phone-number fired"))
162163
aws_pinpoint_client.validate_phone_number("01", recipient)
163164

164165

app/job/rest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ def create_job(service_id):
242242
original_file_name = data.get("original_file_name")
243243
data.update({"service": service_id})
244244
try:
245-
current_app.logger.info(f"#s3-partitioning DATA IN CREATE_JOB: {data}")
245+
current_app.logger.info(
246+
f"#notify-debug-s3-partitioning DATA IN CREATE_JOB: {data}"
247+
)
246248
data.update(**get_job_metadata_from_s3(service_id, data["id"]))
247249
except KeyError:
248250
raise InvalidRequest(

app/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ def serialize_for_redis(self, obj):
17091709
value = (obj.created_at.strftime("%Y-%m-%d %H:%M:%S"),)
17101710
elif column.name in ["sent_at", "completed_at"]:
17111711
value = None
1712-
elif column.name.endswith("_id"):
1712+
elif column.name.endswith("_id") or column.name == "id":
17131713
value = getattr(obj, column.name)
17141714
value = str(value)
17151715
else:

app/notifications/process_notifications.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def persist_notification(
145145
# it's just too hard with redis and timing to test this here
146146
if os.getenv("NOTIFY_ENVIRONMENT") == "test":
147147
dao_create_notification(notification)
148+
elif "verify_code" in str(notification.personalisation):
149+
dao_create_notification(notification)
150+
148151
else:
149152
redis_store.rpush(
150153
"message_queue",

0 commit comments

Comments
 (0)