You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validation is too strict; executing a trigger as a user without a last name silently fails, even though the same user may execute commands in chat with no problem.
Here, we see that the last name is required. Updating the user to add a last name an re-executing the trigger shows it working as expected.
cogctl users update chris --last-name=Maier
curl --request POST
--verbose
--header "Content-Type: application/json"
http://localhost:4001/v1/triggers/dad68d88-37a0-46c4-89bf-e041404a375c
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4001 (#0)> POST /v1/triggers/dad68d88-37a0-46c4-89bf-e041404a375c HTTP/1.1
> Host: localhost:4001
> User-Agent: curl/7.43.0
> Accept: */*> Content-Type: application/json
>< HTTP/1.1 200 OK
< server: Cowboy
< date: Wed, 14 Dec 2016 01:38:18 GMT
< content-length: 26
< content-type: application/json; charset=utf-8
< cache-control: max-age=0, private, must-revalidate
< x-request-id: ss13j5lu48bv6sjph6suoqhs4v2cukk3
<* Connection #0 to host localhost left intact
[{"body":["Hello World"]}]%
Cause
The error is encountered in Cog.Chat.Adapter. Because the message does not validate, we treat it as invalid and do no further processing on it. However, since it has come in via a trigger, it's already in the system; if it was valid enough at the outside of the system, it should be valid deeper inside.
The fact that a user without a last name can still execute commands via chat indicates that there are two different paths that requests are taking. If a user can execute a command, they should be able to execute it regardless of how it is called.
Thoughts
Why is a last name required to execute a command via trigger? Is there some place where we are assuming the presence of a last name, perhaps for messaging or logging purposes? Can that be replaced with something else?
How many places are relying on validation by the Cog.Chat.User struct? Do any of those require a last name? Can these uses be reconciled?
Which other validations are in excess of what is strictly required? This ticket is in terms of "last name", but only because that happens to be how it was found; there could be others.
Is there any circumstance in which a trigger execution can be submitted to the system and legitimately fail at this point? If so, how can that be conveyed back to the requestor as a failure? This should never return an HTTP 202 to the user.
If we do in fact require a last name (or any other data, for that matter), then this should be reflected in the creation and update validation logic on our users. I should not be able to create a user in Cog that cannot actually use Cog.
The text was updated successfully, but these errors were encountered:
Validation is too strict; executing a trigger as a user without a last name silently fails, even though the same user may execute commands in chat with no problem.
Replication Steps
cogctl triggers create \ --name test-trigger \ --pipeline "echo 'Hello World'" \ --as-user=chris
The request processing times out, returning a 202 to the requestor. However, the server logs reveal the following:
Here, we see that the last name is required. Updating the user to add a last name an re-executing the trigger shows it working as expected.
Cause
The error is encountered in Cog.Chat.Adapter. Because the message does not validate, we treat it as invalid and do no further processing on it. However, since it has come in via a trigger, it's already in the system; if it was valid enough at the outside of the system, it should be valid deeper inside.
The fact that a user without a last name can still execute commands via chat indicates that there are two different paths that requests are taking. If a user can execute a command, they should be able to execute it regardless of how it is called.
Thoughts
Cog.Chat.User
struct? Do any of those require a last name? Can these uses be reconciled?The text was updated successfully, but these errors were encountered: