Skip to content
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: add request_id in order for the API to track the request #167

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

goudyj
Copy link
Collaborator

@goudyj goudyj commented Mar 12, 2025

In this PR, we add a request_id to request in order for the API to track them and not process twice the same request if one take more than the timeout (30 s)

Summary by Sourcery

Adds a request_id to each request to allow the API to track requests and avoid processing duplicates in case of timeouts.

@goudyj goudyj requested a review from Darkheir March 12, 2025 10:32
Copy link

sourcery-ai bot commented Mar 12, 2025

Reviewer's Guide by Sourcery

This PR adds a request_id to the requests sent by the API to track them and prevent processing the same request multiple times due to timeouts. The request_id is implemented as a UUID. The tests were updated to assert the presence of the event_id in the request body.

Sequence diagram for sending a request with request_id

sequenceDiagram
    participant Module
    participant API

    Module->>Module: Generate request_id (UUID)
    Module->>API: Send request with data and request_id
    API->>API: Process request
    API-->>Module: Response
Loading

File-Level Changes

Change Details Files
Added a request_id to the data sent in the request.
  • Added request_id to the data dictionary before sending the request.
  • The request_id is a UUID to ensure uniqueness.
sekoia_automation/module.py
Updated tests to assert the presence of event_id in the request body.
  • Added assertions to check for the existence of event_id in the JSON payload of the first and last requests.
  • Refactored assertions to extract the JSON payload before performing individual checks.
tests/test_action.py
tests/test_account_validator.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @goudyj - I've reviewed your changes - here's some feedback:

Overall Comments:

  • It looks like you're adding event_id to the tests but not asserting its value, consider checking that it is a valid UUID.
  • Consider generating the request_id in the _send_request method using uuid4() to ensure uniqueness.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

github-actions bot commented Mar 12, 2025

Test Results

223 tests  +1   222 ✅ +1   2m 3s ⏱️ +18s
  1 suites ±0     1 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 2beb005. ± Comparison against base commit 5b90ad2.

♻️ This comment has been updated with latest results.

@goudyj goudyj requested a review from gaelmuller March 12, 2025 14:34
@goudyj goudyj force-pushed the feat/add-event-id-to-request branch from 78fafb7 to 6d3be44 Compare March 12, 2025 16:39
Copy link

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.76%. Comparing base (5b90ad2) to head (2beb005).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #167   +/-   ##
=======================================
  Coverage   90.76%   90.76%           
=======================================
  Files          35       35           
  Lines        2500     2501    +1     
=======================================
+ Hits         2269     2270    +1     
  Misses        231      231           

☔ 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.

@goudyj goudyj requested a review from gaelmuller March 12, 2025 16:51
Copy link
Collaborator

@gaelmuller gaelmuller left a 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.

I think you need to update the Changelog + version though

@goudyj goudyj requested a review from gaelmuller March 12, 2025 17:06
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.

2 participants