⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(sentry): review-batch fixes across provision scripts and specs
justina6792e6b1b4f
diff --git a/.env.sample b/.env.sampleindex 33224e726..f449953bb 100644--- a/.env.sample+++ b/.env.sample@@ -82,7 +82,7 @@ SMTP_REQUIRE_TLS=# SENTRY_TRACES_SAMPLE_RATE=0.1 # 0.0 disables; default 0 (opt-in)# SENTRY_PROFILES_SAMPLE_RATE=0.1 # 0.0 disables; default 0 (opt-in)# SENTRY_RELEASE= # git SHA; ties events to source maps. Falls back to package.json version.-# SENTRY_API_TOKEN= # Used by scripts/provision-sentry-alerts.sh. Scope: org:write. https://sentry.io/settings/account/api/auth-tokens/+# SENTRY_API_TOKEN= # Used by scripts/provision-sentry-alerts.sh and scripts/provision-sentry-dashboards.sh. Scope: org:write. https://sentry.io/settings/account/api/auth-tokens/# Kaneo Cloud billing via Creem (Optional): only active when KANEO_CLOUD=true# and both keys are set. Self-hosted installs leave these empty; billing stays off.diff --git a/scripts/provision-sentry-alerts.sh b/scripts/provision-sentry-alerts.shindex e6e3aa916..ede7f5f41 100755--- a/scripts/provision-sentry-alerts.sh+++ b/scripts/provision-sentry-alerts.sh@@ -76,6 +76,8 @@ api_call() {local tmptmp=$(mktemp)+ local curl_err+ curl_err=$(mktemp)local status# --fail-with-body: exit non-zero on HTTP error, but still write the body# to stdout (curl 7.76+). Lets us capture error responses inline.@@ -86,14 +88,21 @@ api_call() {-H "Authorization: Bearer ${SENTRY_API_TOKEN}" \-H "Content-Type: application/json" \"${body_args[@]}" \- "$url" 2>/dev/null) || {+ "$url" 2>"$curl_err") || {err "HTTP ${status:-?} from $method $url"err "Request body: $body"err "Response body:"[ -s "$tmp" ] && sed 's/^/ /' "$tmp" >&2 || echo " (empty)" >&2- rm -f "$tmp"+ # Surface transport-level diagnostics (DNS, TLS, timeout) when no+ # HTTP response was produced. Helpful when the API is unreachable.+ if [ -s "$curl_err" ]; then+ err "curl:"+ sed 's/^/ /' "$curl_err" >&2+ fi+ rm -f "$tmp" "$curl_err"return 1}+ rm -f "$curl_err"cat "$tmp"rm -f "$tmp"}@@ -109,11 +118,28 @@ list_monitors() {api_call GET "${API_BASE}/organizations/${ORG}/monitors/"}+list_detectors() {+ api_call GET "${API_BASE}/organizations/${ORG}/detectors/"+}++# Find an existing detector by name. Returns the numeric id, or empty string.+# Returns non-zero if the list call itself failed.+find_detector_by_name() {+ local name="$1"+ local response+ response=$(list_detectors) || return 1+ echo "$response" | jq -r --arg name "$name" \+ '.[] | select(.name == $name) | .id' | head -n1+}+find_existing_workflow() {# Returns the full workflow object as compact JSON, or empty string.+ # Returns non-zero if the list call itself failed (network, auth, etc.) —+ # callers must distinguish "no match" from "lookup failed" so they can+ # skip the alert rather than silently create a duplicate.local name="$1"local response- response=$(list_workflows) || return 0+ response=$(list_workflows) || return 1echo "$response" | jq -c --arg name "$name" \'.[] | select(.name == $name)' | head -n1}@@ -141,12 +167,11 @@ create_or_update_workflow() {}create_or_update_detector() {- local project="$1"- local body="$2"- local id="${3:-}"+ local body="$1"+ local id="${2:-}"local method=POST# Detectors are organization-scoped. The project lives in the body- # (`projectId`), not the URL — `/projects/${project}/detectors/` returns+ # (`projectId`), not the URL — `/projects/{project}/detectors/` returns# 200 on POST but 404 on PUT, so the update path always failed.local url="${API_BASE}/organizations/${ORG}/detectors/"if [ -n "$id" ]; then@@ -191,7 +216,11 @@ for i in $(seq 0 $((COUNT - 1))); do# Find existing workflow (full object, or empty string). The script# discriminates create vs update on whether this returns a value.- EXISTING=$(find_existing_workflow "$NAME")+ if ! EXISTING=$(find_existing_workflow "$NAME"); then+ err " failed to look up existing workflow \u2014 skipping"+ ERRORS=$((ERRORS + 1))+ continue+ fiEXISTING_ID=""if [ -n "$EXISTING" ]; thenEXISTING_ID=$(echo "$EXISTING" | jq -r '.id // empty')@@ -262,15 +291,21 @@ for i in $(seq 0 $((COUNT - 1))); doDETECTOR=$(echo "$ALERT" | jq --arg org "$ORG" --arg project "$PROJECT" '.detector + {organizationId: $org, projectId: $project}')+ DETECTOR_NAME=$(echo "$DETECTOR" | jq -r '.name')- # On update, find the existing detector id from the workflow's- # detectorIds. On create, it is empty.+ # Resolve the existing detector id. The workflow's detectorIds is+ # authoritative when the workflow exists, but a previous failed run+ # can leave an orphaned detector behind. Falling back to a name+ # lookup keeps idempotent re-runs from creating a duplicate.EXISTING_DET_ID=""if [ -n "$EXISTING_ID" ]; thenEXISTING_DET_ID=$(echo "$EXISTING" | jq -r '.detectorIds[0] // empty')fi+ if [ -z "$EXISTING_DET_ID" ]; then+ EXISTING_DET_ID=$(find_detector_by_name "$DETECTOR_NAME" || true)+ fi- if NEW_DET_ID=$(create_or_update_detector "$PROJECT" "$DETECTOR" "$EXISTING_DET_ID") && [ -n "$NEW_DET_ID" ]; then+ if NEW_DET_ID=$(create_or_update_detector "$DETECTOR" "$EXISTING_DET_ID") && [ -n "$NEW_DET_ID" ]; thenif [ -n "$EXISTING_DET_ID" ]; thenok "Updated detector $NEW_DET_ID"elsediff --git a/scripts/provision-sentry-dashboards.sh b/scripts/provision-sentry-dashboards.shindex 4214e37c9..abb596ce7 100755--- a/scripts/provision-sentry-dashboards.sh+++ b/scripts/provision-sentry-dashboards.sh@@ -90,9 +90,17 @@ list_dashboards() {}# Find existing dashboard by title. Returns the full dashboard object.+# Returns non-zero if the list call itself failed (network, auth, etc.) —+# callers must distinguish "no match" from "lookup failed" so they can+# skip the dashboard rather than silently create a duplicate.find_dashboard_by_title() {local title="$1"- list_dashboards | jq -c --arg title "$title" \+ local response+ # Capture the list output so its exit status is preserved. Without this,+ # a failed pipeline (list_dashboards | jq ...) would always look like+ # "no match" because the jq side swallows the api_call failure.+ response=$(list_dashboards) || return 1+ echo "$response" | jq -c --arg title "$title" \'.[] | select(.title == $title)' | head -n1}@@ -140,7 +148,11 @@ for i in $(seq 0 $((COUNT - 1))); doechoinfo "==== $TITLE ===="- EXISTING=$(find_dashboard_by_title "$TITLE")+ if ! EXISTING=$(find_dashboard_by_title "$TITLE"); then+ err " failed to look up existing dashboard \u2014 skipping"+ ERRORS=$((ERRORS + 1))+ continue+ fiEXISTING_ID=""if [ -n "$EXISTING" ]; thenEXISTING_ID=$(echo "$EXISTING" | jq -r '.id // empty')@@ -161,6 +173,7 @@ for i in $(seq 0 $((COUNT - 1))); doBODY=$(echo "$DASHBOARD" | jq --argjson existing "$EXISTING" '{title: $existing.title,+ description: ($existing.description // .description // null),widgets: .widgets| map(. + {datasetSource: "user"}+ (if .displayType == "table" then {} else {limit: 10} end))@@ -181,6 +194,7 @@ for i in $(seq 0 $((COUNT - 1))); doBODY=$(echo "$DASHBOARD" | jq '{title: .title,+ description: .description,widgets: .widgets| map(. + {datasetSource: "user"}+ (if .displayType == "table" then {} else {limit: 10} end))diff --git a/sentry/alerts.json b/sentry/alerts.jsonindex f00d4aba7..a8b047a97 100644--- a/sentry/alerts.json+++ b/sentry/alerts.json@@ -150,7 +150,7 @@"dataSources": [{"dataset": "events_analytics_platform",- "query": "transaction:*/api/mcp/* http.status_code:>=500 is_transaction:true",+ "query": "transaction:*/api/mcp/* is_transaction:true","queryType": 1,"aggregate": "failure_rate()","timeWindow": 3600,diff --git a/sentry/dashboards.json b/sentry/dashboards.jsonindex 1fd5549c1..797bac306 100644--- a/sentry/dashboards.json+++ b/sentry/dashboards.json@@ -247,7 +247,7 @@"fields": ["count()", "time"],"aggregates": ["count()"],"columns": ["time"],- "query": "event.type:transaction monitor.check_in_id:* monitor.status:missed_or_failed",+ "query": "event.type:transaction monitor.check_in_id:* (monitor.status:missed OR monitor.status:error)","orderby": "time","limit": 10}