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: failed request assertion not found #1340

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

Conversation

syamsudotdev
Copy link
Contributor

Monika Pull Request (PR)

What feature/issue does this PR add

This PR resolves #1330

How did you implement / how did you fix it

  1. Move probe handling logic from monika.ts to config component
  2. Add probe sanitization during config validation
  3. Add tests for config sanitization
  4. Make failed request assertion ID deterministic

How to test

  1. Create following config
probes:
  - id: 'http-1'
    name: 'status-401-test'
    requests:
      - url: https://httpbin.org/status/401
        method: PATCH
    alerts:
      - assertion: response.status < 200 or response.status > 308
        message: HTTP Status is not 200
      - assertion: response.ime > 2000
        message: Too sloow
  1. npm run start -- --config monika.yml
  2. Observe log WARN: 2025-01-05T10:30:46.044Z 1 id:http-1 ERROR: ECONNREFUSED: Attempted to connect to a server, but the server declined the connection. Ensure the server is running and accepting connections., NOTIF: Service probably down
  3. Observe desktop notification "Probe is not accessible"

- Move probe handling logic from monika.ts to config component
- Add probe sanitization during config validation
- Add tests for config sanitization
- Make failed request assertion ID deterministic
Copy link

codecov bot commented Jan 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.33%. Comparing base (6a29470) to head (8e43a07).
Report is 33 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1340      +/-   ##
==========================================
+ Coverage   62.51%   63.33%   +0.81%     
==========================================
  Files         112      110       -2     
  Lines        3391     3461      +70     
  Branches      591      592       +1     
==========================================
+ Hits         2120     2192      +72     
+ Misses       1079     1078       -1     
+ Partials      192      191       -1     

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

@dennypradipta
Copy link
Contributor

I recently stumbled upon this issue too while working on my PR. I just added the default assertion either way

https://github.com/hyperjumptech/monika/pull/1338/files#diff-3aac4c8237169d4825c0691cd95ac08ca18fc792a02c9ee0a20e30be5365bbc1

Didn't know which one is the best solution though

@syamsudotdev
Copy link
Contributor Author

I recently stumbled upon this issue too while working on my PR. I just added the default assertion either way

https://github.com/hyperjumptech/monika/pull/1338/files#diff-3aac4c8237169d4825c0691cd95ac08ca18fc792a02c9ee0a20e30be5365bbc1

Didn't know which one is the best solution though

IMO this PR's change, i.e. moving the default assertions to config sanitation step would be more ideal

Copy link
Contributor

@sapiderman sapiderman left a comment

Choose a reason for hiding this comment

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

this works for me. thanks @syamsudotdev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to read assertion Error
3 participants