Skip to content

fix: all: add correct source in cloud events#311

Merged
jjrodrig merged 5 commits intomainfrom
fix/source-in-cloud-events
Sep 24, 2025
Merged

fix: all: add correct source in cloud events#311
jjrodrig merged 5 commits intomainfrom
fix/source-in-cloud-events

Conversation

@haritzsaiz
Copy link
Collaborator

This pull request introduces improvements to the handling of AWS IoT policy updates, source context propagation, and source formatting in the backend. The main changes focus on ensuring that only new or changed AWS IoT policies are registered or updated, refining how source context is set and propagated, and updating the format of the AWS IoT source string.

AWS IoT Policy Management

  • Enhanced the logic in createOrUpdateDMSHandler to register or update only new or changed AWS IoT policies during automatic registration, reducing unnecessary operations.

Source Context Handling

  • In EventPublisherWithSourceMiddleware, added a check to ensure the source context is set only if it's missing, preventing overwriting an existing source.
  • Updated the updateContextWithRequestWithSource function to set the source context directly from the header value without prefixing it, simplifying source extraction.

Source Formatting

  • Changed the format of the AWS IoT source string in AWSIoTSource to use a new URI scheme for improved clarity and consistency.

Minor Cleanup

  • Removed an unused fmt import from the basic-header-extractors/extractors.go file.

Signed-off-by: hsaizsierra <[email protected]>
@codecov
Copy link

codecov bot commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 11.11111% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.68%. Comparing base (ed3f519) to head (1e4db6e).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
connectors/awsiot/pkg/event-handlers.go 0.00% 39 Missing ⚠️
connectors/awsiot/pkg/service.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #311      +/-   ##
==========================================
- Coverage   46.86%   46.68%   -0.18%     
==========================================
  Files         136      136              
  Lines        9769     9810      +41     
==========================================
+ Hits         4578     4580       +2     
- Misses       4800     4839      +39     
  Partials      391      391              
Flag Coverage Δ
backend 58.37% <100.00%> (+0.01%) ⬆️
connector-awsiot 4.88% <2.43%> (-0.15%) ⬇️
core 63.09% <ø> (ø)
monolithic 0.00% <ø> (ø)
sdk 0.00% <ø> (ø)
shared-http 7.07% <ø> (ø)
storage-postgres 54.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: hsaizsierra <[email protected]>
@jjrodrig jjrodrig requested a review from Copilot September 24, 2025 12:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request improves AWS IoT policy management and cloud event source handling by implementing selective policy updates, refining source context propagation, and standardizing source URI format.

  • Enhanced AWS IoT policy registration to only update new or changed policies during automatic registration
  • Fixed source context handling to prevent overwriting existing source values
  • Updated AWS IoT source URI format and removed HTTP prefix from source headers

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
connectors/awsiot/pkg/models.go Updated AWS IoT source URI format to use new scheme
connectors/awsiot/pkg/event-handlers.go Added logic to selectively register/update only new or changed AWS IoT policies
backend/pkg/routes/middlewares/basic-header-extractors/extractors_test.go Updated test to match new source format without HTTP prefix
backend/pkg/routes/middlewares/basic-header-extractors/extractors.go Removed unused fmt import and HTTP prefix from source header processing
backend/pkg/middlewares/eventpub/utils.go Added check to prevent overwriting existing source context
backend/pkg/assemblers/dms-manager_events_test.go Added missing defer statement for router cleanup

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

jjrodrig and others added 3 commits September 24, 2025 14:58
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Juanjo Rodriguez <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Juanjo Rodriguez <[email protected]>
@sonarqubecloud
Copy link

@jjrodrig jjrodrig merged commit 267245b into main Sep 24, 2025
37 checks passed
@haritzsaiz haritzsaiz deleted the fix/source-in-cloud-events branch November 7, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants