Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

[WIP] [Feature] Pass webhook id to handlers #606

Merged
merged 4 commits into from
Dec 2, 2022

Conversation

jbwyme
Copy link
Contributor

@jbwyme jbwyme commented Nov 21, 2022

WHY are these changes introduced?

Fixes #370

WHAT is this pull request doing?

Grabs the webhook id from the 'X-Shopify-Webhook-Id' header and passes it to the webhook handlers.

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above
  • I have added/updated tests for this change
  • I have documented new APIs/updated the documentation for modified APIs (for public APIs)

Copy link
Contributor Author

@jbwyme jbwyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unnecessary new line

@scottdixon
Copy link
Contributor

Hey @jbwyme, thanks for adding this!

Checks are failing on Not all authors have signed a CLA or have a GitHub account associated with their email.

Can you please sign Shopify’s CLA. Also are you able to add a test?

Copy link
Contributor

@paulomarg paulomarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you! I think we can merge this once we make the type parameter optional.

src/webhooks/types.ts Outdated Show resolved Hide resolved
Comment on lines +391 to +393
if (!webhookId) {
missingHeaders.push(ShopifyHeader.WebhookId);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this header isn't strictly necessary for validation, I wonder if we want to fail on it missing. That being said, we should always have the header so I suppose there's no harm in checking 🙂.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's optional in the WebhookHandlerFunction type, so it probably shouldn't be mandatory here. The existing tests aren't passing because of this check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2c: It's optional in the type for backwards compatibility but the expected behavior is the header always exists. Therefore, I'd argue this is more correct. However, it's a minor nit and it probably doesn't matter much either way. Happy to go either direction!

@jbwyme
Copy link
Contributor Author

jbwyme commented Nov 30, 2022

Thanks for the review! I got side tracked but I'll finish out this PR today.

@jbwyme jbwyme requested a review from paulomarg November 30, 2022 20:14
@paulomarg
Copy link
Contributor

I think the code looks good, but we seem to have a few tests breaking because they're not setting up the id header in the mocks, could you please fix those so we can merge?

@jbwyme
Copy link
Contributor Author

jbwyme commented Dec 1, 2022

That's what I get for trying to do the whole PR in the github editor :D

@paulomarg paulomarg merged commit 21f095e into Shopify:main Dec 2, 2022
@shopify-shipit shopify-shipit bot temporarily deployed to production December 5, 2022 14:13 Inactive
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Access to webhook id in handlers
4 participants