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

refactor: populate key-value depending on their content #308

Merged

Conversation

mohamed-gougam
Copy link
Contributor

Proposed changes

Context:
During the design phase of Violation Context backend APIs, a decision was made to improve the logic of how the violation contexts are populated in the Agent.

Proposed solution:
The UI design for the Violation Context tables contains the violation context key, violation context value and the count. If we look at the actual data for what these will contain, often there may be only the key or only the value (and not both) that are populated. Often in these cases fully understanding the key or value requires also the name of the violation itself. For example:

{
    "violation_name": "VIOL_HEADER_REPEATED",
    "violation_context": "header",
    "context_key": "Cookie",
    "context_value": ""
}

In this case, our API would return context_key = ‘Cookie’ and an empty context_value with count = 1. From the user's standpoint they are seeing that a cookie caused some violation, but it’s not directly apparent what was the actual failure - namely that the cookie was repeated. If VIOL_HEADER_REPEATED were returned in the response, then it would be fairly easy to understand.

Another example:

{
    "violation_name": "VIOL_PARAMETER_EMPTY_VALUE",
    "violation_context": "parameter",
    "context_key": "a",
    "context_value": ""
}

One way to fix the above is to always shift the key to context_value if context_value is empty and then populate context_key with the violation_name. So the Violation Context above would become:

{
    "context_key": "Parameter empty value",
    "context_value": "a",
    "count": 10
}

Acceptance criteria:

  • Ensure that the context_key and context_value are actionable to the user when used together (the user will also have the violation_context available).
  • Update/add unit and component tests

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@netlify
Copy link

netlify bot commented May 8, 2023

Deploy Preview for agent-public-docs canceled.

Name Link
🔨 Latest commit 542575b
🔍 Latest deploy log https://app.netlify.com/sites/agent-public-docs/deploys/646602fff3ff960008a56b02

@github-actions github-actions bot added chore Pull requests for routine tasks dependencies labels May 8, 2023
@mohamed-gougam mohamed-gougam force-pushed the nap-monitoring-violation-context-key-value-population branch from 76fc4bc to 35926f2 Compare May 9, 2023 14:45
@github-actions github-actions bot added the documentation Improvements or additions to documentation label May 9, 2023
@mohamed-gougam mohamed-gougam force-pushed the nap-monitoring-violation-context-key-value-population branch from 35926f2 to 661855e Compare May 9, 2023 14:46
Copy link
Contributor

@sanathkumarbs sanathkumarbs left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for adding the support to correctly populate the key-value and also for the additional test cases! 🙌

@mohamed-gougam mohamed-gougam force-pushed the nap-monitoring-violation-context-key-value-population branch from 661855e to 580b10c Compare May 10, 2023 13:10
@mohamed-gougam mohamed-gougam force-pushed the nap-monitoring-violation-context-key-value-population branch 4 times, most recently from 892b224 to 1dedcd5 Compare May 16, 2023 13:47
@mohamed-gougam mohamed-gougam force-pushed the nap-monitoring-violation-context-key-value-population branch from 1dedcd5 to 542575b Compare May 18, 2023 10:50
@oliveromahony oliveromahony merged commit fda5ae8 into main May 25, 2023
@oliveromahony oliveromahony deleted the nap-monitoring-violation-context-key-value-population branch May 25, 2023 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for routine tasks dependencies documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants