# Build trigger API fails on certain commit message

**URL:** <https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700>\
**Category:** Tooling Issues\
**Created:** [April 4, 2018, 12:41am UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700 "2018-04-04T00:41:06Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![koral](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/koral/32/357_2.png) [@koral](https://discuss.bitrise.io/u/koral)\
**Post date:** [April 4, 2018, 12:41am UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/1 "2018-04-04T00:41:06Z")

</div>

Here is the curl snippet:

```auto
curl https://www.bitrise.io/app/<stripped>/build/start.json --data '{"hook_info":{"type":"bitrise","api_token":"<stripped>"},"build_params":{"branch":"master","commit_message":"- CommitMessage: Update dependency eslint-plugin-react to v7.7.0\nThis Pull Request updates dependency [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) from `v7.6.1` to `v7.7.0`\n<details>\n<summary>Release Notes</summary>\n### [`v7.7.0`](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#770---2018-02-19)\n##### Added\n* [`forbid-foreign-prop-types`][]: add `allowInPropTypes` option ([#1655][] @iansu)\n* Add [`jsx-max-depth`][] rule ([#1260][] @chriswong)\n##### Fixed\n* [`no-access-state-in-setstate`][]: Exclude references to this.state in setState callback ([#1610][] @pfhayes)\n* [`no-danger-with-children`][]: prevent infinite loop ([#1571][] @ljharb)\n* [`sort-prop-types`][]: Fix sortShapeProp when shape is not an object literal ([#1669][] @justinanastos)\n* [`jsx-child-element-spacing`][]: fix error location ([#1666][] @pfhayes)\n* [`no-unused-prop-types`][]: fix for createClass ([#1675][] @yuri-sakharov)\n* [`prop-types`][]: include nextProps checking in shouldComponentUpdate ([#1690][] @amerryma)\n* [`jsx-curly-spacing`][]: refactor to fix start and end-braces in a single pass ([#1414][] @s-h-a-d-o-w)\n##### Changed\n* [`jsx-child-element-spacing`][]: add missing docs ([#1665][] @pfhayes); fix docs ([#1670][] @SammyM)\n[7.7.0]: https://github.com/yannickcr/eslint-plugin-react/compare/v7.6.1...v7.7.0\n[#1690]: https://github.com/yannickcr/eslint-plugin-react/pull/1690\n[#1675]: https://github.com/yannickcr/eslint-plugin-react/pull/1675\n[#1670]: https://github.com/yannickcr/eslint-plugin-react/pull/1670\n[#1669]: https://github.com/yannickcr/eslint-plugin-react/pull/1669\n[#1666]: https://github.com/yannickcr/eslint-plugin-react/pull/1666\n[#1655]: https://github.com/yannickcr/eslint-plugin-react/pull/1655\n[#1610]: https://github.com/yannickcr/eslint-plugin-react/pull/1610\n[#1414]: https://github.com/yannickcr/eslint-plugin-react/pull/1414\n[#1260]: https://github.com/yannickcr/eslint-plugin-react/pull/1260\n[#1571]: https://github.com/yannickcr/eslint-plugin-react/issue/1571\n---\n</details>\n<details>\n<summary>Commits</summary>\n#### v7.7.0\n- [`cfd3959`](https://github.com/yannickcr/eslint-plugin-react/commit/cfd3959ff8e3b11262b0006dff28d0c957b282a2) [Docs] add `jsx-child-element-spacing`\n- [`70e8a02`](https://github.com/yannickcr/eslint-plugin-react/commit/70e8a023ee6d37ccd090161a747a8c35ca78081c) Merge pull request [#1610](https://github.com/yannickcr/eslint-plugin-react/issues/1610) from pfhayes/setstate\n- [`5e1a64c`](https://github.com/yannickcr/eslint-plugin-react/commit/5e1a64c14f8fda5e186991b1e09a55f476a64e27) [Fix] `no-danger-with-children`: prevent infinite loop\n- [`d8dff26`](https://github.com/yannickcr/eslint-plugin-react/commit/d8dff2639d7085ccbf9dd52d027e787f1494c962) test(sort-prop-types) Add failing test for when `sortShapeProp` is true and shape not object literal\n- [`17ac433`](https://github.com/yannickcr/eslint-plugin-react/commit/17ac433b4d97659b74cf682b7e79d48542a13822) fix(sort-prop-types): Fix sortShapeProp when shape is not an object literal\n- [`d818f2b`](https://github.com/yannickcr/eslint-plugin-react/commit/d818f2b87eb4edd0ecbb4f3839389e75cc38bc00) Merge pull request [#1669](https://github.com/yannickcr/eslint-plugin-react/issues/1669) from justinanastos/fix/sort-prop-types-shape-no-properties-1668\n- [`05c49d4`](https://github.com/yannickcr/eslint-plugin-react/commit/05c49d4d322f255fbdc304a7593a1471dd0a781a) [Fix] `jsx-child-element-spacing`: fix error location\n- [`2839b5d`](https://github.com/yannickcr/eslint-plugin-react/commit/2839b5d4c618450d094ab9715a95eff7b7e30942) Fix an issue with the documentation for 'jsx-child-element-spacing'\n- [`d318e52`](https://github.com/yannickcr/eslint-plugin-react/commit/d318e52826d27b291edad0bf9dca0d3f09ea01aa) Remove failing test for renamed React import\n- [`dda03e9`](https://github.com/yannickcr/eslint-plugin-react/commit/dda03e934468f4b2b6f088146e070296a64ae463) Created test\n- [`78e2951`](https://github.com/yannickcr/eslint-plugin-react/commit/78e29517a285d905f109b62dccab0f76d10dc219) Fixed bug\n- [`b1444be`](https://github.com/yannickcr/eslint-plugin-react/commit/b1444be8dd8dc56a5936e540487dc2e8e3eb0d3b) Added more tests\n- [`24658b5`](https://github.com/yannickcr/eslint-plugin-react/commit/24658b56968d25c1b0fb4f3f238c7abbf4f4b5ba) Added more valid tests\n- [`3d83d13`](https://github.com/yannickcr/eslint-plugin-react/commit/3d83d13fe1900c8b16f7f65019e38d83e98746e5) Added more tests\n- [`fb2fefd`](https://github.com/yannickcr/eslint-plugin-react/commit/fb2fefd05cd28f0f4f021d82a26b7bb0105e4637) Merge pull request [#1675](https://github.com/yannickcr/eslint-plugin-react/issues/1675) from yuri-sakharov/fix/react-no-unused-prop-types\n- [`90e3767`](https://github.com/yannickcr/eslint-plugin-react/commit/90e3767221a59f85f6f31e54f4a0c9d67be120c1) Update no-unused-prop-types rule for new React class component lifecycles\n- [`c0c7ce0`](https://github.com/yannickcr/eslint-plugin-react/commit/c0c7ce0847ce4cc3d5cae927792835d9c9ad120e) Update no-unused-prop-types rule to be aware of 16.3 lifecycle changes\n- [`352642f`](https://github.com/yannickcr/eslint-plugin-react/commit/352642ff43d77368dfc1b54b3206cdab37c0df46) Add common use-case tests and fix bugs\n- [`830fc3d`](https://github.com/yannickcr/eslint-plugin-react/commit/830fc3d4a05d341234b6c0954b91e7938ca2ff4f) Fix lint errors\n- [`0f480f6`](https://github.com/yannickcr/eslint-plugin-react/commit/0f480f63600d6e8f4aae04196e0672609eae7bed) Add commented-out createClass tests\n- [`0e2e046`](https://github.com/yannickcr/eslint-plugin-react/commit/0e2e0463cb73663d7d2ead66b7418c574ffd9704) [Dev Deps] update `babel-eslint`, `eslint`, `istanbul`, `mocha`\n- [`abe8381`](https://github.com/yannickcr/eslint-plugin-react/commit/abe8381c0d6748047224c430ce47f02e40160ed0) Update CHANGELOG and bump version\n</details>\n---\nThis PR has been generated by [Renovate Bot](https://renovateapp.com).\n - WorkflowID: android\n - BranchDest: master","workflow_id":"t"},"triggered_by":"curl"}'

```

Response:

```auto
* We are completely uploaded and fine
< HTTP/1.1 500 Internal Server Error
< Server: Cowboy
< Date: Wed, 04 Apr 2018 00:36:42 GMT
< Connection: keep-alive
< Content-Length: 77
< Via: 1.1 vegur
<
An unhandled lowlevel error occurred. The application logs may have details.

```

And original issue: [https://github.com/DroidsOnRoids/bitrise-step-trigger-bitrise-workflow/issues/5](https://github.com/DroidsOnRoids/bitrise-step-trigger-bitrise-workflow/issues/5)

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 3:55pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/2 "2018-04-05T15:55:46Z")

</div>

Hi @koral,

The issue is that the commit message includes `'` (`'jsx-child-element-spacing'`) in your above curl call.

If you want to use the trigger api with more complex inputs I’d suggest you to not to use Bash/curl for that, but instead use Go or Ruby or another script language which supports proper JSON serialization.

The above `curl` call will not work because `--data '{..` \<- you used a single quote as the starting char of the `data` string, but the commit message includes `'` too, so that will end the string and the rest will be interpreted by Bash as a param for `curl`, not as the content of the `--data`.

If you’d have any questions just let us know! 😉

---

<div class="post-metadata">

**Author:** ![koral](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/koral/32/357_2.png) [@koral](https://discuss.bitrise.io/u/koral)\
**Post date:** [April 5, 2018, 5:00pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/3 "2018-04-05T17:00:25Z")

</div>

It does not work either from Go. See the linked issue and Go source code.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 5:20pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/4 "2018-04-05T17:20:51Z")

</div>

Can you provide a sample data set we could use to reproduce this issue?

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 5:24pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/5 "2018-04-05T17:24:42Z")

</div>

I tried with the Commit Message from [https://github.com/DroidsOnRoids/bitrise-step-trigger-bitrise-workflow/issues/5](https://github.com/DroidsOnRoids/bitrise-step-trigger-bitrise-workflow/issues/5) and it worked perfectly for me (not with `curl`, but from the Web UI, which uses the same endpoint).

---

<div class="post-metadata">

**Author:** ![koral](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/koral/32/357_2.png) [@koral](https://discuss.bitrise.io/u/koral)\
**Post date:** [April 5, 2018, 5:38pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/6 "2018-04-05T17:38:09Z")

</div>

Here is the JSON serialization: [https://github.com/DroidsOnRoids/bitrise-step-trigger-bitrise-workflow/blob/develop/main.go#L101](https://github.com/DroidsOnRoids/bitrise-step-trigger-bitrise-workflow/blob/develop/main.go#L101)  
Just tried with same commit message: [https://www.bitrise.io/build/da18eb0c8d421b34](https://www.bitrise.io/build/da18eb0c8d421b34)

Any suggestion how to fix that?

Anyway, even if client sends malformed request shouldn’t API respond with error 400 instead of 500?

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 6:19pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/7 "2018-04-05T18:19:32Z")

</div>

> [@koral](#):
>
> Anyway, even if client sends malformed request shouldn’t API respond with error 400 instead of 500?

The error `invalid character 'A' looking for beginning of value` is coming from the de-serializer code at: [https://github.com/DroidsOnRoids/bitrise-step-trigger-bitrise-workflow/blob/425bd841945fa7c07a59d9b7555f7763d561ff4b/main.go#L132](https://github.com/DroidsOnRoids/bitrise-step-trigger-bitrise-workflow/blob/425bd841945fa7c07a59d9b7555f7763d561ff4b/main.go#L132) - it’s not the error our server returns. Most likely the server returns a non JSON response here, and so the `json.Unmarshal` line returns a JSON unmarshal error as the content is not a valid JSON body.

Strange indeed, will try to check why a 500 is returned 🤔

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 6:20pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/8 "2018-04-05T18:20:46Z")

</div>

Happy to see that it’s not just me who has a “Sandbox” / “testing” app registered on [bitrise.io](http://bitrise.io) solely for testing configs quickly 😉

---

<div class="post-metadata">

**Author:** ![koral](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/koral/32/357_2.png) [@koral](https://discuss.bitrise.io/u/koral)\
**Post date:** [April 5, 2018, 6:47pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/9 "2018-04-05T18:47:40Z")

</div>

That non-JSON response is already attached in the 1st post: `An unhandled lowlevel error occurred. The application logs may have details.`.

Step indeed fails to parse responses which are not JSONs but still a real issue is that such response is returned by API.

It looks like a bug on server side or maybe in Go JSON marshaller so API receives an invalid request. I don’t see anything which I can fix on the step side.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 6:52pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/10 "2018-04-05T18:52:50Z")

</div>

> [@koral](#):
>
> That non-JSON response is already attached in the 1st post

Indeed, sorry I missed that.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 7:06pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/11 "2018-04-05T19:06:48Z")

</div>

After a bit of debugging this seems to be related to the length of the commit message. Not sure yet why, and why the server returns 500, but testing with the commit message and deleting parts of it it eventually works, regardless of from where you delete lines from the reported commit/build msg param, so it’s most likely related to its length.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 7:15pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/12 "2018-04-05T19:15:36Z")

</div>

It seems it’s not just the length… Anyway, we’ll definitely debug this more, thanks for reporting! We’ll update you here once we can figure out what the issue is and a fix is deployed! 🙂

---

<div class="post-metadata">

**Author:** ![gergelybekesi](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/gergelybekesi/32/1321_2.png) [@gergelybekesi](https://discuss.bitrise.io/u/gergelybekesi)\
**Post date:** [April 19, 2018, 5:17pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/13 "2018-04-19T17:17:23Z")

</div>

Hey there @koral,

Seems to me that your request is missing a header, I’ve added the `Content-Type` header with the value `applicaiton/json` and it seemed to work for me. Somehow the body of the request is either cropped or some encoding issue.

Let me know if this solves the issue for you too 😉

---

<div class="post-metadata">

**Author:** ![koral](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/koral/32/357_2.png) [@koral](https://discuss.bitrise.io/u/koral)\
**Post date:** [April 19, 2018, 6:35pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/14 "2018-04-19T18:35:13Z")

</div>

Yep, it fixes the issue.  
So it seems that documentation on devcenter should be updated. Here: [https://devcenter.bitrise.io/api/build-trigger/#curl-example-generator](https://devcenter.bitrise.io/api/build-trigger/#curl-example-generator) there is nothing about `Content-Type`, curl snippets don’t specify it.

I’ve just created a PR with new step version on steplib.

---

<div class="post-metadata">

**Author:** ![gergelybekesi](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/gergelybekesi/32/1321_2.png) [@gergelybekesi](https://discuss.bitrise.io/u/gergelybekesi)\
**Post date:** [April 20, 2018, 7:09am UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/15 "2018-04-20T07:09:10Z")

</div>

Definitely, that header should be mentioned in the Devcenter description, so I’ll complete the documentation. Thank you for the notice 🙂

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 30, 2018, 6:54pm UTC](https://discuss.bitrise.io/t/build-trigger-api-fails-on-certain-commit-message/4700/16 "2018-04-30T18:54:09Z")

</div>

Closed on April 30, 2018, 6:54pm UTC


