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

Cachet returns bad request if component_status is missing in request #1789

Closed
lhorace opened this issue May 16, 2016 · 7 comments
Closed

Cachet returns bad request if component_status is missing in request #1789

lhorace opened this issue May 16, 2016 · 7 comments
Assignees
Milestone

Comments

@lhorace
Copy link

@lhorace lhorace commented May 16, 2016

Before submitting your issue, please make sure that you've checked all of the checkboxes below.

  • You're running the latest release version of Cachet.
  • Ensure that you're running at least PHP 5.5.9, you can check this by running php -v
  • You've ran rm -rf bootstrap/cache/* from the root of your Cachet installation.

To help us better understand your issue, please answer the following — cheers!

Your setup

  • What version of Cachet?
    2.2.1
  • What database driver? MySQL? Postgres? SQLite?
    MySQL
  • What version of PHP?
    5.6.99-hhvm

Hello,

While testing https://github.com/mpellegrin/nagios-eventhandler-cachet with Cachet. Upon creating incidents, the server appears to incorrectly respond with HTTP 400 BAD REQUEST, and throws an exception:

Validation errors:
The status format is invalid.
Stack trace:
#0 /var/www/vhosts/status.lhprojects.net/cachet/vendor/alt-three/validator/src/ValidatingObserver.php(54): AltThree\Validator\ValidatingObserver->validate()
#1 (): AltThree\Validator\ValidatingObserver->saving()
#2 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(348): call_user_func_array()
#3 (): Closure$Illuminate\Events\Dispatcher::createClassListener()
#4 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(221): call_user_func_array()
#5 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(164): Illuminate\Events\Dispatcher->fire()
#6 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1679): Illuminate\Events\Dispatcher->until()
#7 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1466): Illuminate\Database\Eloquent\Model->fireModelEvent()
#8 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1422): Illuminate\Database\Eloquent\Model->save()
#9 /var/www/vhosts/status.lhprojects.net/cachet/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php(99): Illuminate\Database\Eloquent\Model->update()
#10 (): CachetHQ\Cachet\Bus\Handlers\Commands\Incident\ReportIncidentCommandHandler->handle()
#11 /var/www/vhosts/status.lhprojects.net/cachet/vendor/alt-three/bus/src/Dispatcher.php(225): call_user_func()
#12 (): Closure$AltThree\Bus\Dispatcher::dispatchNow()
#13 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(150): call_user_func()
#14 (): Closure$Illuminate\Pipeline\Pipeline::getInitialSlice()
#15 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func()
#16 /var/www/vhosts/status.lhprojects.net/cachet/vendor/alt-three/bus/src/Dispatcher.php(226): Illuminate\Pipeline\Pipeline->then()
#17 /var/www/vhosts/status.lhprojects.net/cachet/vendor/alt-three/bus/src/Dispatcher.php(201): AltThree\Bus\Dispatcher->dispatchNow()
#18 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(323): AltThree\Bus\Dispatcher->dispatch()
#19 /var/www/vhosts/status.lhprojects.net/cachet/app/Http/Controllers/Api/IncidentController.php(81): dispatch()
#20 (): CachetHQ\Cachet\Http\Controllers\Api\IncidentController->postIncidents()
#21 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(80): call_user_func_array()
#22 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(146): Illuminate\Routing\Controller->callAction()
#23 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(95): Illuminate\Routing\ControllerDispatcher->call()
#24 (): Closure$Illuminate\Routing\ControllerDispatcher::callWithinStack()
#25 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func()
#26 (): Closure$Illuminate\Routing\Pipeline::getInitialSlice()
#27 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func()
#28 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(96): Illuminate\Pipeline\Pipeline->then()
#29 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(54): Illuminate\Routing\ControllerDispatcher->callWithinStack()
#30 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Route.php(174): Illuminate\Routing\ControllerDispatcher->dispatch()
#31 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Route.php(140): Illuminate\Routing\Route->runController()
#32 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(725): Illuminate\Routing\Route->run()
#33 (): Closure$Illuminate\Routing\Router::runRouteWithinStack()
#34 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func()
#35 /var/www/vhosts/status.lhprojects.net/cachet/app/Http/Middleware/ApiAuthentication.php(67): Closure$Illuminate\Routing\Pipeline::getInitialSlice()
#36 (): CachetHQ\Cachet\Http\Middleware\ApiAuthentication->handle()
#37 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array()
#38 (): Closure$Illuminate\Pipeline\Pipeline::getSlice()
#39 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func()
#40 /var/www/vhosts/status.lhprojects.net/cachet/app/Http/Middleware/Timezone.php(53): Closure$Illuminate\Routing\Pipeline::getSlice()
#41 (): CachetHQ\Cachet\Http\Middleware\Timezone->handle()
#42 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array()
#43 (): Closure$Illuminate\Pipeline\Pipeline::getSlice()
#44 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func()
#45 /var/www/vhosts/status.lhprojects.net/cachet/app/Http/Middleware/Acceptable.php(35): Closure$Illuminate\Routing\Pipeline::getSlice()
#46 (): CachetHQ\Cachet\Http\Middleware\Acceptable->handle()
#47 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array()
#48 (): Closure$Illuminate\Pipeline\Pipeline::getSlice()
#49 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func()
#50 /var/www/vhosts/status.lhprojects.net/cachet/vendor/barryvdh/laravel-cors/src/HandleCors.php(34): Closure$Illuminate\Routing\Pipeline::getSlice()
#51 (): Barryvdh\Cors\HandleCors->handle()
#52 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array()
#53 (): Closure$Illuminate\Pipeline\Pipeline::getSlice()
#54 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func()
#55 (): Closure$Illuminate\Routing\Pipeline::getSlice()
#56 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func()
#57 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\Pipeline\Pipeline->then()
#58 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(699): Illuminate\Routing\Router->runRouteWithinStack()
#59 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->dispatchToRoute()
#60 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(246): Illuminate\Routing\Router->dispatch()
#61 (): Closure$Illuminate\Foundation\Http\Kernel::dispatchToRouter()
#62 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func()
#63 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Closure$Illuminate\Routing\Pipeline::getInitialSlice()
#64 (): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#65 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array()
#66 (): Closure$Illuminate\Pipeline\Pipeline::getSlice()
#67 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func()
#68 /var/www/vhosts/status.lhprojects.net/cachet/vendor/fideloper/proxy/src/TrustProxies.php(46): Closure$Illuminate\Routing\Pipeline::getSlice()
#69 (): Fideloper\Proxy\TrustProxies->handle()
#70 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array()
#71 (): Closure$Illuminate\Pipeline\Pipeline::getSlice()
#72 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func()
#73 (): Closure$Illuminate\Routing\Pipeline::getSlice()
#74 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func()
#75 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then()
#76 /var/www/vhosts/status.lhprojects.net/cachet/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#77 /var/www/vhosts/status.lhprojects.net/cachet/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle()
#78 {main} {"identification":{"id":"222cc03d-d4c9-489a-beeb-5a7bbc325558"}}

Although the validation check has failed, it still continues to process the request, and create the incident.

Seems like issue CastawayLabs/cachet-monitor#28 is related.

Upon further investigation, it appears your request will fail validation if you supply component_id without component_status. Although https://docs.cachethq.io/docs/incidents doesn't state component_status as a requirement to component_id, in fact, it's reverse.

Here's my working copy of the script:
https://scm.lhprojects.net/LHProjects-Network/Scripts/files/db154bb6ca895d4ce1582b31f4cc174ce3b6a8d4/cachet_notify

Expected behaviour

Return HTTP 200

Actual behaviour

Returns HTTP 400 and the incident is created regardless.

Steps to reproduce

  1. Download the PHP script above
  2. Edit the URL and KEY
  3. Execute script with paremeters

Regards

@GrahamCampbell
Copy link
Member

@GrahamCampbell GrahamCampbell commented May 20, 2016

Please let us know the exact HTTP request you are sending to cachet.

@GrahamCampbell GrahamCampbell added this to the V2.3.0 milestone May 20, 2016
@jbrooksuk
Copy link
Member

@jbrooksuk jbrooksuk commented May 23, 2016

So, this is only an issue when you're creating a new incident? And you're not supplying a component to update?

@lhorace
Copy link
Author

@lhorace lhorace commented May 24, 2016

This issue can be reproducible here https://docs.cachethq.io/docs/incidents.

See https://www.youtube.com/watch?v=HKEgEpj5-9w&feature=youtu.be.

As noted earlier, when you get back a HTTP 400 (syntax failure) when creating a new incident with component_id supplied but missing component_status. The incident is still created regardless. Although the documentation isn't clear if component_status is required when supplying component_id.

I reference other bug reports, the incident is still created, although a failure occured.

Regards

@jbrooksuk
Copy link
Member

@jbrooksuk jbrooksuk commented May 24, 2016

This is not a bug 😄

If you supply the component field, then you must supply the component_status field. I can see why this is confusing, the error message says status.

In v2.3.0 we've fixed the issue where the issue was still being created, regardless of the error.

@GrahamCampbell is there anything we can do to fix the error message? I think we've discussed this previously.

@jbrooksuk jbrooksuk closed this May 24, 2016
@jbrooksuk jbrooksuk self-assigned this May 24, 2016
@lhorace
Copy link
Author

@lhorace lhorace commented May 24, 2016

This finally makes sense to me now 'Component to update. (Required with component_status)', the wording threw me off.

Regards

@jbrooksuk
Copy link
Member

@jbrooksuk jbrooksuk commented May 24, 2016

Sorry about that @lhorace, I'll get the documentation updated when I can :)

@lhorace
Copy link
Author

@lhorace lhorace commented May 24, 2016

No problem, take your time :) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.