-
-
Notifications
You must be signed in to change notification settings - Fork 238
Description
Environment
self-hosted/on-premise @ 22.1.0
Which SDK and version?
@sentry/cli: 1.73.2
nodejs: v16.13.1
Steps to Reproduce
Note: I have redacted some information like returned json payload in the successful case, projects list & the real backend origin... however the idea & relevant info should be, I believe, intact.
The problem is that when I run the binary manually (either through the path returned by yarn bin sentry-cli or through yarn run sentry-cli) I'm getting what I need.
However, I need to run this programmatically because I need to upload source maps after webpack compilation completes.
The command below is a basis for connection testing routine used before webpack compilation starts so that I can validate sentry connection details in the compilation ENV as soon as possible.
When running the binary directly in my bash session
pool/web-ui ❯ /opt/dev/braiins/pool/web-ui/.yarn/unplugged/@sentry-cli-npm-1.73.2-cc2f072cf0/node_modules/@sentry/cli/sentry-cli projects list DEBUG 2022-03-09 23:14:24.010599970 +01:00 sentry-cli version: 1.73.2, platform: "linux", architecture: "x86_64" INFO 2022-03-09 23:14:24.010770434 +01:00 sentry-cli was invoked with the following command line: "/opt/dev/braiins/pool/web-ui/.yarn/unplugged/@sentry-cli-npm-1.73.2-cc2f072cf0/node_modules/@sentry/cli/sentry-cli" "projects" "list" DEBUG 2022-03-09 23:14:24.011745605 +01:00 request GET https://host.zone/api/0/organizations/braiins/projects/?cursor= DEBUG 2022-03-09 23:14:24.011834628 +01:00 using token authentication DEBUG 2022-03-09 23:14:24.011890054 +01:00 retry number 0, max retries: 0 DEBUG 2022-03-09 23:14:24.074444039 +01:00 > GET /api/0/organizations/braiins/projects/?cursor= HTTP/1.1 DEBUG 2022-03-09 23:14:24.074475956 +01:00 > Host: host.zone DEBUG 2022-03-09 23:14:24.074487049 +01:00 > Accept: */* DEBUG 2022-03-09 23:14:24.074496671 +01:00 > Connection: TE DEBUG 2022-03-09 23:14:24.074507949 +01:00 > TE: gzip DEBUG 2022-03-09 23:14:24.074530133 +01:00 > User-Agent: sentry-cli/1.73.2 DEBUG 2022-03-09 23:14:24.075059347 +01:00 > Authorization: Bearer 4249615e*** DEBUG 2022-03-09 23:14:24.193780068 +01:00 < HTTP/1.1 200 OK DEBUG 2022-03-09 23:14:24.193853113 +01:00 < Server: nginx DEBUG 2022-03-09 23:14:24.193888338 +01:00 < Date: Wed, 09 Mar 2022 22:14:24 GMT DEBUG 2022-03-09 23:14:24.193924584 +01:00 < Content-Type: application/json DEBUG 2022-03-09 23:14:24.193957496 +01:00 < Content-Length: 5279 DEBUG 2022-03-09 23:14:24.193989830 +01:00 < Link: <http://host.zone/api/0/organizations/braiins/projects/?&cursor=100:-1:1>; rel="previous"; results="false"; cursor="100:-1:1", <http://host.zone/api/0/organizations/braiins/projects/?&cursor=100:1:0>; rel="next"; results="false"; cursor="100:1:0" DEBUG 2022-03-09 23:14:24.194026293 +01:00 < Allow: GET, HEAD, OPTIONS DEBUG 2022-03-09 23:14:24.194055251 +01:00 < Access-Control-Allow-Methods: GET, HEAD, OPTIONS DEBUG 2022-03-09 23:14:24.194099544 +01:00 < Access-Control-Allow-Headers: X-Sentry-Auth, X-Requested-With, Origin, Accept, Content-Type, Authentication, Authorization, Content-Encoding DEBUG 2022-03-09 23:14:24.194131914 +01:00 < Access-Control-Expose-Headers: X-Sentry-Error, Retry-After DEBUG 2022-03-09 23:14:24.194162147 +01:00 < Access-Control-Allow-Origin: * DEBUG 2022-03-09 23:14:24.194191054 +01:00 < X-Sentry-Rate-Limit-Remaining: 619 DEBUG 2022-03-09 23:14:24.194220616 +01:00 < X-Sentry-Rate-Limit-Limit: 620 DEBUG 2022-03-09 23:14:24.194250624 +01:00 < X-Sentry-Rate-Limit-Reset: 1646864065 DEBUG 2022-03-09 23:14:24.194281041 +01:00 < Vary: Accept-Language, Cookie DEBUG 2022-03-09 23:14:24.194311472 +01:00 < Content-Language: en DEBUG 2022-03-09 23:14:24.194341051 +01:00 < X-Frame-Options: deny DEBUG 2022-03-09 23:14:24.194370260 +01:00 < X-Content-Type-Options: nosniff DEBUG 2022-03-09 23:14:24.194399649 +01:00 < X-XSS-Protection: 1; mode=block DEBUG 2022-03-09 23:14:24.194460280 +01:00 response status: 200 DEBUG 2022-03-09 23:14:24.195633979 +01:00 body: [{…redacted…}] +----+---------------+-----------------+--------------+ | ID | Slug | Team | Name | +----+---------------+-----------------+--------------+ | 1 | internal | Sentry | Internal | | …and other projects… | +----+---------------+-----------------+--------------+
When running through bash script
Note: I get the same in nodejs with either of execa[Sync] / subprocess.execFile[Sync]
pool/web-ui ❯ shared/dev/sentry/assertConnection "${SENTRY_DSN}" "http://host.zone" 4
DEBUG 2022-03-09 23:14:33.479761679 +01:00 sentry-cli version: 1.73.2, platform: "linux", architecture: "x86_64"
INFO 2022-03-09 23:14:33.479802906 +01:00 sentry-cli was invoked with the following command line: "/opt/dev/braiins/pool/web-ui/.yarn/unplugged/@sentry-cli-npm-1.73.2-cc2f072cf0/node_modules/@sentry/cli/sentry-cli" "projects" "list"
DEBUG 2022-03-09 23:14:33.480007790 +01:00 request GET http://host.zone/api/0/organizations/braiins/projects/?cursor=
DEBUG 2022-03-09 23:14:33.480020122 +01:00 using token authentication
DEBUG 2022-03-09 23:14:33.480026442 +01:00 retry number 0, max retries: 0
DEBUG 2022-03-09 23:14:33.501056255 +01:00 > GET /api/0/organizations/braiins/projects/?cursor= HTTP/1.1
DEBUG 2022-03-09 23:14:33.501090426 +01:00 > Host: host.zone
DEBUG 2022-03-09 23:14:33.501104349 +01:00 > Accept: */*
DEBUG 2022-03-09 23:14:33.501116583 +01:00 > Connection: TE
DEBUG 2022-03-09 23:14:33.501130517 +01:00 > TE: gzip
DEBUG 2022-03-09 23:14:33.501144724 +01:00 > User-Agent: sentry-cli/1.73.2
DEBUG 2022-03-09 23:14:33.501838970 +01:00 > Authorization: Bearer 4249615e***
DEBUG 2022-03-09 23:14:33.508177910 +01:00 < HTTP/1.1 302 Found
DEBUG 2022-03-09 23:14:33.508219011 +01:00 < Cache-Control: no-cache
DEBUG 2022-03-09 23:14:33.508236392 +01:00 < Content-length: 0
DEBUG 2022-03-09 23:14:33.508253790 +01:00 < Location: https://host.zone/api/0/organizations/braiins/projects/?cursor=
DEBUG 2022-03-09 23:14:33.508338620 +01:00 response status: 302
DEBUG 2022-03-09 23:14:33.508369493 +01:00 body:
error: not a JSON response
Here is the content of the assertConnection file.
I though, that this might work out given what I observed and I'd run this script with prepared arguments from nodejs.
#!/usr/bin/env bash
# Will throw when connection to sentry instance declared
# in env variables cannot be established by sentry-cli or when returned
# list of projects does not include one declared in env variable.
set -e
DIR_HERE=$(realpath "$(dirname "$0")")
DIR_WEBUI="$(realpath "$DIR_HERE"/../..)/"
function fail {
printf >&2 "%s: ERROR: %s\n" "$SELF" "$*"
exit 1
}
function succeed {
printf >&2 "%s: INFO: %s\n" "$SELF" "$*"
exit 0
}
DSN=${1}
ORIGIN=${2}
PROJECT_ID=${3}
[[ -z "${DSN}" ]] && fail '"DSN" missing!'
[[ -z "${ORIGIN}" ]] && fail '"ORIGIN" missing!'
[[ -z "${PROJECT_ID}" ]] && fail '"PROJECT_ID" missing!'
cd "${DIR_WEBUI}"
export SENTRY_ORG="braiins"
export SENTRY_URL="${ORIGIN}"
$(yarn bin sentry-cli) projects list