Skip to content

test: fix cloud functional tests - #585

Open
margaretjgu wants to merge 6 commits into
mainfrom
fix/cloud-functional-skip-missing
Open

test: fix cloud functional tests#585
margaretjgu wants to merge 6 commits into
mainfrom
fix/cloud-functional-skip-missing

Conversation

@margaretjgu

@margaretjgu margaretjgu commented Sep 1, 2026

Copy link
Copy Markdown
Member

Skip empty-org item GETs and public QA 404s so Cloud functional tests can fail the build. CI creates search, observability, and security projects, traffic filters, and a hosted deployment when those lists are empty. Relates to #584.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ BASH shellcheck 2 0 0 0.27s
✅ COPYPASTE jscpd yes no no 0.53s
✅ REPOSITORY gitleaks yes no no 55.79s
✅ REPOSITORY git_diff yes no no 0.1s
✅ REPOSITORY secretlint yes no no 10.82s
✅ REPOSITORY trivy yes no no 25.7s
✅ TYPESCRIPT eslint 3 0 0 3.77s
✅ YAML yamllint 1 0 0 0.79s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

github-actions[bot]

This comment was marked as outdated.

@margaretjgu margaretjgu changed the title fix: skip missing cloud functional items fix: fix cloud functional tests Sep 1, 2026
@margaretjgu margaretjgu changed the title fix: fix cloud functional tests test: fix cloud functional tests Sep 1, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jq // fallbacks error when .items is missing, so non-items Cloud list shapes break under set -e.

jq -r '
if type == "array" then .[0].id // empty
else
.items[0].id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// does not catch jq errors. On a non-array object, .items[0].id throws Cannot index null with number whenever .items is absent, so the .projects / .filters / .rulesets / .deployments alternatives never run. With set -euo pipefail, ensure then aborts on a successful list like {"deployments":[{"id":"d1"}]}. Use try/catch (or ?) on each path, or pick one array with (.items // .projects // .filters // .rulesets // .deployments // [])[0].id.

// `try` so a nested path like `.regions[0].id` against a bare array
// yields empty instead of aborting the script (jq cannot index an
// array with a string).
lines.push(`${indent}${bashVar}=$(echo "$RESPONSE" | jq -r 'try (${jqPath} // empty) catch empty')`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same jq pitfall in the skipEmptySet fallback: .items[0].id errors on objects that are not {items:[...]} (e.g. {"deployments":[]} after the primary path already yielded empty). skipNotFound also emits set -e, so that error aborts the script instead of reaching the SKIP. Wrap the fallback in try/catch empty (or only fall back when type=="array").

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants