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

RM API: provide useful feedback when trigger action is malformed #750

Merged

Conversation

Annopaolo
Copy link
Collaborator

Display detailed feedback upon failed installation of a trigger with malformed action field.
Under the hood, the Trigger changeset now embeds an Astarte.RealmManagement.API.Triggers.Action changeset that wraps a valid AMQP/HTTP action. Data validation is still performed by the two related modules.
The Action modules handles JSON encoding/decoding, too.
Fixes #748.

@Annopaolo Annopaolo added user experience This issue is about user experience app:realm_management_api This issue or pull request is about astarte_realm_management_api application labels Jan 16, 2023
@Annopaolo Annopaolo requested a review from rbino January 16, 2023 15:30
@codecov
Copy link

codecov bot commented Jan 16, 2023

Codecov Report

Merging #750 (53083ac) into release-1.1 (b89afbb) will decrease coverage by 22.44%.
The diff coverage is n/a.

❗ Current head 53083ac differs from pull request most recent head 83e6ac7. Consider uploading reports for the commit 83e6ac7 to get more accurate results

@@               Coverage Diff                @@
##           release-1.1     #750       +/-   ##
================================================
- Coverage        68.43%   46.00%   -22.44%     
================================================
  Files              258       17      -241     
  Lines             5911      300     -5611     
================================================
- Hits              4045      138     -3907     
+ Misses            1866      162     -1704     
Impacted Files Coverage Δ
...tarte_realm_management_api/triggers/amqp_action.ex
...tarte_realm_management_api/triggers/http_action.ex
...b/astarte_realm_management_api/triggers/trigger.ex
.../lib/astarte_realm_management_api_web/telemetry.ex
...b/astarte_appengine_api_web/plug/authorize_path.ex
...nagement_api_web/controllers/trigger_controller.ex
...ata_updater_plant/data_updater/event_type_utils.ex
...ib/astarte_pairing_api_web/views/changeset_view.ex
...i/test/support/astarte_realm_management_mock_db.ex
...i/lib/astarte_pairing_api_web/views/health_view.ex
... and 231 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Annopaolo Annopaolo marked this pull request as ready for review January 17, 2023 15:29
Comment on lines 46 to 56
def encode(
%Action{
http_url: http_url,
http_method: http_method,
http_static_headers: http_static_headers,
template: template,
template_type: template_type
},
opts
)
when not is_nil(http_url) do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Extract only what is needed (i.e. http_url) in the function head, and extract the rest in the body

Comment on lines 68 to 67
%Action{
amqp_exchange: amqp_exchange,
amqp_routing_key: amqp_routing_key,
amqp_static_headers: amqp_headers,
amqp_message_expiration_ms: amqp_message_expiration_ms,
amqp_message_persistent: amqp_message_persistent,
amqp_message_priority: amqp_message_priority
},
opts
)
when not is_nil(amqp_exchange) do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Extract only what is needed (i.e. amqp_exchange) in the function head, and extract the rest in the body

…ormed

Display detailed feedback upon failed installation of a trigger
with malformed action field. Under the hood, the Trigger changeset
now embeds a Action changeset that wraps a valid AMQP/HTTP action.
Validation is still performed by the two related modules.
The Action modules handles JSON encoding/decoding, too.

Signed-off-by: Arnaldo Cesco <arnaldo.cesco@secomind.com>
@rbino rbino merged commit 8f8607c into astarte-platform:release-1.1 Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:realm_management_api This issue or pull request is about astarte_realm_management_api application user experience This issue is about user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants