-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: Don't overwrite req
with parsedReq
#2354
Conversation
req
with parsedReq
Removed vultr server and associated DNS entries |
a117c66
to
b155663
Compare
Right, I've now got some SQL I'm happy with which is tested on staging and locally. We can run this manually on production once this fix is merged (and the SQL is cross-checked please...!). Events without an SELECT
*
FROM
hdb_catalog.hdb_scheduled_events
WHERE
webhook_conf::TEXT ILIKE '%expiry%'
AND status = 'scheduled'
AND payload->'email' IS NULL; Records can be updated with - UPDATE
hdb_catalog.hdb_scheduled_events
SET
payload = jsonb_set(
payload::JSONB,
'{email}',
('"' || public.lowcal_sessions.email || '"')::JSONB
)
FROM
public.lowcal_sessions
WHERE
webhook_conf::TEXT ILIKE '%expiry%'
AND status = 'scheduled'
AND payload->'email' IS NULL
AND hdb_scheduled_events.payload->>'sessionId' = public.lowcal_sessions.id::TEXT;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
@@ -16,7 +16,7 @@ import { SanitiseApplicationData } from "./service/sanitiseApplicationData/types | |||
import { sanitiseApplicationData } from "./service/sanitiseApplicationData"; | |||
|
|||
export const sendSlackNotificationController: SendSlackNotification = async ( | |||
req, | |||
_req, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
Am I right in saying _req
is still being passed in despite not being used directly as down the chain it is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, _req
is always passed in, but no longer used in this instance. We're using the underscore prefix to indicate that this is an unused variable - there's a linting rule set up for this in .eslintrc
under @typescript-eslint/no-unused-vars
This looks as if it would do what you're intending as far as I can see. Can you remind me where you'd actually run this? Also, I'm happy to jump on a call to go through this 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes & proposed SQL look good to me here 👍
One question about the SQL - the email
param is only expected in payloads for session reminders and expiry events, right? Not, payment_
reminder & expiry too? Just double checking we're catching everything expected with this update.
This is a good question! I've double checked this and invite to pay emails just need a planx-new/hasura.planx.uk/metadata/tables.yaml Lines 895 to 902 in 4e29137
|
I'm going to go ahead and merge this - I'll run the SQL once this has got to production and will then update this PR with a paper trail confirming it's been done successfully. |
What's the problem?
A "reminder" email failed this morning - the reason for this was that the required "email" field was missing from the event sent to Hasura.
What caused this?
This field was missed when typing the schema for this endpoint. This happened as the
routeSendEmailRequest()
function is not yet typed - meaning the variable was missed.What's the solution?
req
withparsedReq
- this change means that non-updated endpoints shouldn't fail as the originalreq
object is not touched. I'm now writing tores.locals
(docs) which is a nice solution to the issue I was talking about in a previous dev call. We can now coerce types as part of validation in the middleware, and not break existing endpoints - this feels like a solid solution here.Next steps...
I think it's pretty likely that multiple reminder and expiry events setup since this change was made are affected by this problem of a missing email field. These events should be identifiable from the Hasura
hdb_catalog
tables, and we could then append emails to them. I'll update this thread as I troubleshoot this one.This might also point towards considering a cron job for these events as an alternative to manage reminder and expiry events. Something to consider!