Cannot parse the payload received from a CircleCI web hook

Hi, we are using CircleCI to run some of the tests of our project Pouch on Github. And we need payload data to obtain info of pull requests. But it seems that we cannot unmarsal the payload data.
Here is the log I get:
time="2018-06-21T09:58:14Z" level=error msg="failed to process CircleCI notification: invalid character '$' after object key:value pair"
Can you quote the data before post the payload? Otherwise there is no way for me to process data and get the info I need.
[ \"${HOME}\" = \"/\" ] [ -n \"$CIRCLE_TAG\" ]
stuffs like this in payload will caused the failure of unmarsalling.

What payload are you referring to?

Hi, @halfer

I would like to explain this issue.

The payload is jsonstringify, like

... \"name\":\"Checkout code\",\"bash_command\":\"#!/bin/sh\\nset -e\\n\\n# Workaround old docker images with incorrect $HOME\\n# check https://github.com/docker/docker/issues/2968 for details\\nif [ \"${HOME}\" = \"/\" ]....

I think the " in the value should be quoted. However, the webhook doesn’t quote “{HOME}\" into \\\"{HOME}\” (the key is bash_command). For the receiver, we cannot parse the string into json because of the quoted.

Is it clear to you?

Thanks
Wei Fu

Not really - there’s some concepts you’re introducing here without any context. You mention a webhook - what webhook? Is this a webhook from GitHub or BitBucket called on repo push?

Yes. repo push and the webhook from Github

  1. Would you provide a whole webhook JSON sample, with a small amount of snipping for security if necessary, to illustrate the problem?

  2. Are you saying the JSON is invalid?

  3. If there is an issue with a webhook from GitHub, isn’t the issue at GitHub, not CircleCI?

Sure. Here is the sample:

time="2018-06-21T09:04:48Z" level=info msg="{\"payload\":{\"compare\":null,\"previous_successful_build\":{\"build_num\":5163,\"status\":\"success\",\"build_time_millis\":5883},\"build_parameters\":{\"CIRCLE_JOB\":\"markdownlint-misspell-shellcheck\"},\"oss\":true,\"all_commit_details_truncated\":false,\"committer_date\":null,\"steps\":[{\"name\":\"Spin up Environment\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"Spin up Environment\",\"bash_command\":null,\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:43.072Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"output_url\":\"https://circle-production-action-output.s3.amazonaws.com/fe39fd100044b634d1a6b2b5-alibaba-pouch-0-0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20180621T090447Z&X-Amz-SignedHeaders=host&X-Amz-Expires=431999&X-Amz-Credential=AKIAIQ65EYQDTMSJK2DQ%2F20180621%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=186c54427eb2a6d2c2874e75c2bfb9f209b897f833b829395af0180c11bb0684\",\"start_time\":\"2018-06-21T09:04:29.751Z\",\"background\":false,\"exit_code\":null,\"insignificant\":false,\"canceled\":null,\"step\":0,\"run_time_millis\":13321,\"has_output\":true}]},{\"name\":\"Checkout code\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"Checkout code\",\"bash_command\":\"#!/bin/sh\\nset -e\\n\\n# Workaround old docker images with incorrect $HOME\\n# check https://github.com/docker/docker/issues/2968 for details\\nif [ \"${HOME}\" = \"/\" ]\\nthen\\n  export HOME=$(getent passwd $(id -un) | cut -d: -f6)\\nfi\\n\\nmkdir -p ~/.ssh\\n\\necho 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\\nbitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==\\n' >> ~/.ssh/known_hosts\\n\\n(umask 077; touch ~/.ssh/id_rsa)\\nchmod 0600 ~/.ssh/id_rsa\\n(cat <<EOF > ~/.ssh/id_rsa\\n$CHECKOUT_KEY\\nEOF\\n)\\n\\n# use git+ssh instead of https\\ngit config --global url.\"ssh://git@github.com\".insteadOf \"https://github.com\" || true\\n\\nif [ -e /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}/.git ]\\nthen\\n  cd /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n  git remote set-url origin \"$CIRCLE_REPOSITORY_URL\" || true\\nelse\\n  mkdir -p /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n  cd /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n  git clone \"$CIRCLE_REPOSITORY_URL\" .\\nfi\\n\\nif [ -n \"$CIRCLE_TAG\" ]\\nthen\\n  git fetch --force origin \"refs/tags/${CIRCLE_TAG}\"\\nelse\\n  git fetch --force origin \"pull/1569/head:remotes/origin/pull/1569\"\\nfi\\n\\n\\nif [ -n \"$CIRCLE_TAG\" ]\\nthen\\n  git reset --hard \"$CIRCLE_SHA1\"\\n  git checkout -q \"$CIRCLE_TAG\"\\nelif [ -n \"$CIRCLE_BRANCH\" ]\\nthen\\n  git reset --hard \"$CIRCLE_SHA1\"\\n  git checkout -q -B \"$CIRCLE_BRANCH\"\\nfi\\n\\ngit reset --hard \"$CIRCLE_SHA1\"\",\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:46.336Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"output_url\":\"https://circle-production-action-output.s3.amazonaws.com/2149fd100044b634b2a6b2b5-alibaba-pouch-101-0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20180621T090447Z&X-Amz-SignedHeaders=host&X-Amz-Expires=431999&X-Amz-Credential=AKIAIQ65EYQDTMSJK2DQ%2F20180621%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=26c13b768dee758643facf3982b9a49de1d4e2d7145fba362ec1d889b05fd2e3\",\"start_time\":\"2018-06-21T09:04:43.158Z\",\"background\":false,\"exit_code\":0,\"insignificant\":false,\"canceled\":null,\"step\":101,\"run_time_millis\":3178,\"has_output\":true}]},{\"name\":\"use markdownlint v0.4.0 to lint markdown file (https://github.com/markdownlint/markdownlint)\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"use markdownlint v0.4.0 to lint markdown file (https://github.com/markdownlint/markdownlint)\",\"bash_command\":\"#!/bin/bash -eo pipefail\\nfind  ./ -name  \"*.md\" | grep -v vendor | grep -v commandline |  grep -v .github |  grep -v swagger |  grep -v api |  xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036\\n\",\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:47.013Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"start_time\":\"2018-06-21T09:04:46.341Z\",\"background\":false,\"exit_code\":0,\"insignificant\":false,\"canceled\":null,\"step\":102,\"run_time_millis\":672,\"has_output\":false}]},{\"name\":\"use opensource tool client9/misspell to correct commonly misspelled English words\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"use opensource tool client9/misspell to correct commonly misspelled English words\",\"bash_command\":\"#!/bin/bash -eo pipefail\\nfind  ./* -name  \"*\"  | grep -v vendor | xargs misspell -error\\n\",\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:47.299Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"start_time\":\"2018-06-21T09:04:47.023Z\",\"background\":false,\"exit_code\":0,\"insignificant\":false,\"canceled\":null,\"step\":103,\"run_time_millis\":276,\"has_output\":false}]},{\"name\":\"use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo\",\"bash_command\":\"#!/bin/bash -eo pipefail\\nfind ./ -name \"*.sh\" | grep -v vendor | xargs shellcheck\\n\",\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:47.816Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"start_time\":\"2018-06-21T09:04:47.307Z\",\"background\":false,\"exit_code\":0,\"insignificant\":false,\"canceled\":null,\"step\":104,\"run_time_millis\":509,\"has_output\":false}]}],\"body\":null,\"usage_queued_at\":\"2018-06-21T09:03:40.451Z\",\"context_ids\":[],\"fail_reason\":null,\"retry_of\":null,\"reponame\":\"pouch\",\"ssh_users\":[],\"build_url\":\"https://circleci.com/gh/alibaba/pouch/5166\",\"parallel\":1,\"failed\":false,\"branch\":\"pull/1569\",\"username\":\"alibaba\",\"author_date\":null,\"why\":\"github\",\"user\":{\"is_user\":true,\"login\":\"ZouRui89\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/32304680?v=4\",\"name\":\"Zou Rui\",\"vcs_type\":\"github\",\"id\":32304680},\"vcs_revision\":\"f094a095acd62399fbde881866a18be25e089d41\",\"workflows\":{\"job_name\":\"markdownlint-misspell-shellcheck\",\"job_id\":\"bad4c4f7-aa48-4afc-a350-e81c96eb63e0\",\"workflow_id\":\"550bbda6-70fd-435a-9549-b107635c828a\",\"workspace_id\":\"550bbda6-70fd-435a-9549-b107635c828a\",\"upstream_job_ids\":[],\"upstream_concurrency_map\":{},\"workflow_name\":\"ci\"},\"owners\":[\"ZouRui89\"],\"vcs_tag\":null,\"pull_requests\":[{\"head_sha\":\"f094a095acd62399fbde881866a18be25e089d41\",\"url\":\"https://github.com/alibaba/pouch/pull/1569\"}],\"build_num\":5166,\"infrastructure_fail\":false,\"committer_email\":null,\"has_artifacts\":true,\"previous\":{\"build_num\":5165,\"status\":\"success\",\"build_time_millis\":62380},\"status\":\"success\",\"committer_name\":null,\"retries\":null,\"subject\":null,\"vcs_type\":\"github\",\"timedout\":false,\"dont_build\":null,\"lifecycle\":\"finished\",\"no_dependency_cache\":false,\"stop_time\":\"2018-06-21T09:04:47.824Z\",\"ssh_disabled\":true,\"build_time_millis\":18119,\"picard\":{\"build_agent\":{\"image\":null,\"properties\":{\"build_agent\":\"0.0.6347-92eac3d\",\"executor\":\"docker\"}},\"resource_class\":{\"cpu\":2.0,\"ram\":4096,\"class\":\"medium\"},\"executor\":\"docker\"},\"circle_yml\":{\"string\":\"# Golang CircleCI 2.0 configuration file\\n#\\n# Check https://circleci.com/docs/2.0/language-go/ for more details\\nversion: 2\\njobs:\\n  markdownlint-misspell-shellcheck:\\n    docker:\\n      # this image is build from Dockerfile located in ./.circleci/Dockerfile\\n      - image: allencloud/pouchlint:v0.1\\n    working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n    steps:\\n      - checkout\\n      - run:\\n          name: use markdownlint v0.4.0 to lint markdown file (https://github.com/markdownlint/markdownlint)\\n          command: |\\n            find  ./ -name  \"*.md\" | grep -v vendor | grep -v commandline |  grep -v .github |  grep -v swagger |  grep -v api |  xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036\\n      - run:\\n          name: use opensource tool client9/misspell to correct commonly misspelled English words \\n          command: |\\n            find  ./* -name  \"*\"  | grep -v vendor | xargs misspell -error\\n      - run:\\n          name: use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo\\n          command: |\\n            find ./ -name \"*.sh\" | grep -v vendor | xargs shellcheck\\n\\n  code-check:\\n    docker: \\n      - image: golang:1.9.1\\n    working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n    steps:\\n      - checkout\\n      - run: \\n          name: install golint\\n          command: go get -u golang.org/x/lint/golint\\n      - run: \\n          name: install swagger-0.12.0\\n          command: |\\n            wget --quiet -O /bin/swagger https://github.com/go-swagger/go-swagger/releases/download/0.12.0/swagger_linux_amd64\\n            chmod +x /bin/swagger\\n      - run: \\n          name: use check target in Makefile to check code\\n          command: make check\\n  \\n  unit-test:\\n    docker:\\n      - image: golang:1.9.1\\n    working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n    steps:\\n      - checkout\\n      - run:\\n          name: unit test\\n          command: make unit-test\\n      - run:\\n          name: upload code coverage report\\n          command: bash <(curl -s https://codecov.io/bash)\\nnotify:\\n  webhooks:\\n    - url: http://121.201.63.16:6788/circleci_notifications\\n\\nworkflows:\\n  version: 2\\n  ci:\\n    jobs:\\n      - markdownlint-misspell-shellcheck\\n      - code-check\\n      - unit-test\\n\"},\"messages\":[],\"is_first_green_build\":false,\"job_name\":null,\"start_time\":\"2018-06-21T09:04:29.705Z\",\"canceler\":null,\"all_commit_details\":[],\"platform\":\"2.0\",\"outcome\":\"success\",\"vcs_url\":\"https://github.com/alibaba/pouch\",\"author_name\":null,\"node\":null,\"queued_at\":\"2018-06-21T09:04:27.748Z\",\"canceled\":false,\"author_email\":null}}"
time="2018-06-21T09:04:48Z" level=error msg="failed to process CircleCI notification: invalid character '$' after object key:value pair"

Nothing is wrong with Github, I am afraid.
See, I set the webhook in .circleci/configi.yml in my project Pouch:

notify:
  webhooks:
    - url: http://121.201.63.16:6788/circleci_notifications

just like what your docs mentiond here .
In this case, when the result of pr test finished on CircleCI, the json will be posted to http://121.201.63.16:6788/circleci_notifications from CircleCI.

For clarity: you appear to have given two code samples, not one. It looks like neither XML nor JSON, which I’d expect for a web hook. Are you sure you have indented it correctly?

Oh, I should make it clear: they are not my docs. I am a user of CircleCI, and I volunteer here.

Aha, I think there are two issues here. One person has a hook coming from CircleCI

And another person has a hook coming from GitHub:

This thread is about payloads coming from CircleCI, since that is the first topic.

It is the same case. Sorry for the mistake. It comes from the CircleCI.
I think the circleci officer can help us because the payload is created by the CircleCI…

OK. Here is the exact payload:

"{\"payload\":{\"compare\":null,\"previous_successful_build\":{\"build_num\":5163,\"status\":\"success\",\"build_time_millis\":5883},\"build_parameters\":{\"CIRCLE_JOB\":\"markdownlint-misspell-shellcheck\"},\"oss\":true,\"all_commit_details_truncated\":false,\"committer_date\":null,\"steps\":[{\"name\":\"Spin up Environment\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"Spin up Environment\",\"bash_command\":null,\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:43.072Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"output_url\":\"https://circle-production-action-output.s3.amazonaws.com/fe39fd100044b634d1a6b2b5-alibaba-pouch-0-0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20180621T090447Z&X-Amz-SignedHeaders=host&X-Amz-Expires=431999&X-Amz-Credential=AKIAIQ65EYQDTMSJK2DQ%2F20180621%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=186c54427eb2a6d2c2874e75c2bfb9f209b897f833b829395af0180c11bb0684\",\"start_time\":\"2018-06-21T09:04:29.751Z\",\"background\":false,\"exit_code\":null,\"insignificant\":false,\"canceled\":null,\"step\":0,\"run_time_millis\":13321,\"has_output\":true}]},{\"name\":\"Checkout code\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"Checkout code\",\"bash_command\":\"#!/bin/sh\\nset -e\\n\\n# Workaround old docker images with incorrect $HOME\\n# check https://github.com/docker/docker/issues/2968 for details\\nif [ \"${HOME}\" = \"/\" ]\\nthen\\n  export HOME=$(getent passwd $(id -un) | cut -d: -f6)\\nfi\\n\\nmkdir -p ~/.ssh\\n\\necho 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\\nbitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==\\n' >> ~/.ssh/known_hosts\\n\\n(umask 077; touch ~/.ssh/id_rsa)\\nchmod 0600 ~/.ssh/id_rsa\\n(cat <<EOF > ~/.ssh/id_rsa\\n$CHECKOUT_KEY\\nEOF\\n)\\n\\n# use git+ssh instead of https\\ngit config --global url.\"ssh://git@github.com\".insteadOf \"https://github.com\" || true\\n\\nif [ -e /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}/.git ]\\nthen\\n  cd /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n  git remote set-url origin \"$CIRCLE_REPOSITORY_URL\" || true\\nelse\\n  mkdir -p /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n  cd /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n  git clone \"$CIRCLE_REPOSITORY_URL\" .\\nfi\\n\\nif [ -n \"$CIRCLE_TAG\" ]\\nthen\\n  git fetch --force origin \"refs/tags/${CIRCLE_TAG}\"\\nelse\\n  git fetch --force origin \"pull/1569/head:remotes/origin/pull/1569\"\\nfi\\n\\n\\nif [ -n \"$CIRCLE_TAG\" ]\\nthen\\n  git reset --hard \"$CIRCLE_SHA1\"\\n  git checkout -q \"$CIRCLE_TAG\"\\nelif [ -n \"$CIRCLE_BRANCH\" ]\\nthen\\n  git reset --hard \"$CIRCLE_SHA1\"\\n  git checkout -q -B \"$CIRCLE_BRANCH\"\\nfi\\n\\ngit reset --hard \"$CIRCLE_SHA1\"\",\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:46.336Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"output_url\":\"https://circle-production-action-output.s3.amazonaws.com/2149fd100044b634b2a6b2b5-alibaba-pouch-101-0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20180621T090447Z&X-Amz-SignedHeaders=host&X-Amz-Expires=431999&X-Amz-Credential=AKIAIQ65EYQDTMSJK2DQ%2F20180621%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=26c13b768dee758643facf3982b9a49de1d4e2d7145fba362ec1d889b05fd2e3\",\"start_time\":\"2018-06-21T09:04:43.158Z\",\"background\":false,\"exit_code\":0,\"insignificant\":false,\"canceled\":null,\"step\":101,\"run_time_millis\":3178,\"has_output\":true}]},{\"name\":\"use markdownlint v0.4.0 to lint markdown file (https://github.com/markdownlint/markdownlint)\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"use markdownlint v0.4.0 to lint markdown file (https://github.com/markdownlint/markdownlint)\",\"bash_command\":\"#!/bin/bash -eo pipefail\\nfind  ./ -name  \"*.md\" | grep -v vendor | grep -v commandline |  grep -v .github |  grep -v swagger |  grep -v api |  xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036\\n\",\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:47.013Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"start_time\":\"2018-06-21T09:04:46.341Z\",\"background\":false,\"exit_code\":0,\"insignificant\":false,\"canceled\":null,\"step\":102,\"run_time_millis\":672,\"has_output\":false}]},{\"name\":\"use opensource tool client9/misspell to correct commonly misspelled English words\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"use opensource tool client9/misspell to correct commonly misspelled English words\",\"bash_command\":\"#!/bin/bash -eo pipefail\\nfind  ./* -name  \"*\"  | grep -v vendor | xargs misspell -error\\n\",\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:47.299Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"start_time\":\"2018-06-21T09:04:47.023Z\",\"background\":false,\"exit_code\":0,\"insignificant\":false,\"canceled\":null,\"step\":103,\"run_time_millis\":276,\"has_output\":false}]},{\"name\":\"use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo\",\"actions\":[{\"truncated\":false,\"index\":0,\"parallel\":true,\"failed\":null,\"infrastructure_fail\":null,\"name\":\"use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo\",\"bash_command\":\"#!/bin/bash -eo pipefail\\nfind ./ -name \"*.sh\" | grep -v vendor | xargs shellcheck\\n\",\"status\":\"success\",\"timedout\":null,\"continue\":null,\"end_time\":\"2018-06-21T09:04:47.816Z\",\"type\":\"test\",\"allocation_id\":\"5b2b69ec8748a00007216698-0-build/1EBE0D84\",\"start_time\":\"2018-06-21T09:04:47.307Z\",\"background\":false,\"exit_code\":0,\"insignificant\":false,\"canceled\":null,\"step\":104,\"run_time_millis\":509,\"has_output\":false}]}],\"body\":null,\"usage_queued_at\":\"2018-06-21T09:03:40.451Z\",\"context_ids\":[],\"fail_reason\":null,\"retry_of\":null,\"reponame\":\"pouch\",\"ssh_users\":[],\"build_url\":\"https://circleci.com/gh/alibaba/pouch/5166\",\"parallel\":1,\"failed\":false,\"branch\":\"pull/1569\",\"username\":\"alibaba\",\"author_date\":null,\"why\":\"github\",\"user\":{\"is_user\":true,\"login\":\"ZouRui89\",\"avatar_url\":\"https://avatars3.githubusercontent.com/u/32304680?v=4\",\"name\":\"Zou Rui\",\"vcs_type\":\"github\",\"id\":32304680},\"vcs_revision\":\"f094a095acd62399fbde881866a18be25e089d41\",\"workflows\":{\"job_name\":\"markdownlint-misspell-shellcheck\",\"job_id\":\"bad4c4f7-aa48-4afc-a350-e81c96eb63e0\",\"workflow_id\":\"550bbda6-70fd-435a-9549-b107635c828a\",\"workspace_id\":\"550bbda6-70fd-435a-9549-b107635c828a\",\"upstream_job_ids\":[],\"upstream_concurrency_map\":{},\"workflow_name\":\"ci\"},\"owners\":[\"ZouRui89\"],\"vcs_tag\":null,\"pull_requests\":[{\"head_sha\":\"f094a095acd62399fbde881866a18be25e089d41\",\"url\":\"https://github.com/alibaba/pouch/pull/1569\"}],\"build_num\":5166,\"infrastructure_fail\":false,\"committer_email\":null,\"has_artifacts\":true,\"previous\":{\"build_num\":5165,\"status\":\"success\",\"build_time_millis\":62380},\"status\":\"success\",\"committer_name\":null,\"retries\":null,\"subject\":null,\"vcs_type\":\"github\",\"timedout\":false,\"dont_build\":null,\"lifecycle\":\"finished\",\"no_dependency_cache\":false,\"stop_time\":\"2018-06-21T09:04:47.824Z\",\"ssh_disabled\":true,\"build_time_millis\":18119,\"picard\":{\"build_agent\":{\"image\":null,\"properties\":{\"build_agent\":\"0.0.6347-92eac3d\",\"executor\":\"docker\"}},\"resource_class\":{\"cpu\":2.0,\"ram\":4096,\"class\":\"medium\"},\"executor\":\"docker\"},\"circle_yml\":{\"string\":\"# Golang CircleCI 2.0 configuration file\\n#\\n# Check https://circleci.com/docs/2.0/language-go/ for more details\\nversion: 2\\njobs:\\n  markdownlint-misspell-shellcheck:\\n    docker:\\n      # this image is build from Dockerfile located in ./.circleci/Dockerfile\\n      - image: allencloud/pouchlint:v0.1\\n    working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n    steps:\\n      - checkout\\n      - run:\\n          name: use markdownlint v0.4.0 to lint markdown file (https://github.com/markdownlint/markdownlint)\\n          command: |\\n            find  ./ -name  \"*.md\" | grep -v vendor | grep -v commandline |  grep -v .github |  grep -v swagger |  grep -v api |  xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036\\n      - run:\\n          name: use opensource tool client9/misspell to correct commonly misspelled English words \\n          command: |\\n            find  ./* -name  \"*\"  | grep -v vendor | xargs misspell -error\\n      - run:\\n          name: use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo\\n          command: |\\n            find ./ -name \"*.sh\" | grep -v vendor | xargs shellcheck\\n\\n  code-check:\\n    docker: \\n      - image: golang:1.9.1\\n    working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n    steps:\\n      - checkout\\n      - run: \\n          name: install golint\\n          command: go get -u golang.org/x/lint/golint\\n      - run: \\n          name: install swagger-0.12.0\\n          command: |\\n            wget --quiet -O /bin/swagger https://github.com/go-swagger/go-swagger/releases/download/0.12.0/swagger_linux_amd64\\n            chmod +x /bin/swagger\\n      - run: \\n          name: use check target in Makefile to check code\\n          command: make check\\n  \\n  unit-test:\\n    docker:\\n      - image: golang:1.9.1\\n    working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}\\n    steps:\\n      - checkout\\n      - run:\\n          name: unit test\\n          command: make unit-test\\n      - run:\\n          name: upload code coverage report\\n          command: bash <(curl -s https://codecov.io/bash)\\nnotify:\\n  webhooks:\\n    - url: http://121.201.63.16:6788/circleci_notifications\\n\\nworkflows:\\n  version: 2\\n  ci:\\n    jobs:\\n      - markdownlint-misspell-shellcheck\\n      - code-check\\n      - unit-test\\n\"},\"messages\":[],\"is_first_green_build\":false,\"job_name\":null,\"start_time\":\"2018-06-21T09:04:29.705Z\",\"canceler\":null,\"all_commit_details\":[],\"platform\":\"2.0\",\"outcome\":\"success\",\"vcs_url\":\"https://github.com/alibaba/pouch\",\"author_name\":null,\"node\":null,\"queued_at\":\"2018-06-21T09:04:27.748Z\",\"canceled\":false,\"author_email\":null}}"
1 Like

Seeing that data, I’m not sure I understand the problem - perhaps it is just because I do not work with callbacks.

I would expect the data to be in ordinary JSON, but the string you’ve supplied appears to be backslash-escaped. It’s therefore a JSON representation of a string, not an object, and is thus not parseable (unless it is un-escaped).

Sorry for the late reply. :yum:
Yes, you are right. The payload is not in ordinary JSON, instead it is jsonstringify.

But here is the problem:
I need the payload data to be qualified to be parsed to JSON, otherwise I cannot get the info I need.
And what caused the payload unable to be parsed? The value not quoted.
See, the webhook doesn’t quote “{HOME}" into \"{HOME}\” (the key is bash_command). For the receiver, we cannot parse the string into json.

Can CircleCI team do something about it? Maybe transfer the data(solve the quoted) before posting the payload?

Can you do a cheeky (and temporary) search and replace prior to attempting to convert it to an object? I agree it’s a bit hacky, but it’d get you going again, until a fix can be implemented.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.