Skip to content

Conversation

@alexey-yarmosh
Copy link
Member

The problem was get_token returning: {"errors":[{"message":"Service \"api\" is unavailable. Under pressure.","extensions":{"service":"api","reason":"Under pressure","code":"SERVICE_UNAVAILABLE"}}]}. So I've added retry to curl, + replaced wait-for lib with the one waiting for 2XX response.

@coderabbitai
Copy link

coderabbitai bot commented Oct 16, 2025

Walkthrough

This pull request replaces the custom scripts/wait-for.sh utility with the npm package wait-on (added to dependencies with corresponding TypeScript types). package.json updated accordingly. Seed scripts no longer prefix commands with NODE_ENV=development. scripts/auth.sh now always sources the development env file. scripts/init.sh removes an interactive confirm and switches wait calls to npx wait-on. test/e2e global.setup.ts now uses wait-on with millisecond timeouts. The scripts/wait-for.sh file was removed.

Poem

🎭 A tiny script stepped off the stage,
npm's wait-on took a quiet page,
envs are sourced, tokens fetched in line,
timeouts tick in milliseconds fine,
changes merged — the repo turns the page.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "fix: obtained token is empty" refers to a real aspect of the changeset—the token retrieval issue that this PR addresses. The raw summary confirms the changes involve modifications to get_token and token handling in shell scripts. While the title doesn't explicitly mention the key implementation details (replacing the wait-for library with wait-on, adding retry logic to curl), it does successfully identify the core problem being solved. The title is partially related to the changeset in that it highlights the issue rather than the solution mechanism.
Description Check ✅ Passed The PR description clearly explains both the problem (get_token returning a SERVICE_UNAVAILABLE error response) and the solution (added retry logic to curl and replaced the wait-for library with one waiting for 2XX responses). The description is directly related to the changeset, which includes adding the wait-on package, modifying shell scripts, and updating initialization logic. While concise, the description adequately conveys the intent and key changes without requiring extensive detail.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wait-on

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62a0bfe and e52ba8f.

📒 Files selected for processing (1)
  • scripts/auth.sh (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
scripts/auth.sh (1)
scripts/init.sh (1)
  • get_token (10-14)
🪛 Shellcheck (0.11.0)
scripts/auth.sh

[warning] 8-8: Declare and assign separately to avoid masking return values.

(SC2155)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Run e2e tests
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: Run e2e tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/e2e/global.setup.ts (1)

20-25: Use explicit timeout error matching
wait-on v9.0.1 throws a plain Error with message
“Timed out waiting for: ” (no err.code). Match the full prefix instead of a generic substring:

} catch (err) {
-	if (err.message.includes('Timed out')) {
+	if (err.message?.startsWith('Timed out waiting for: ')) {
		console.log(`Service at ${url} not running. Starting…`);
	} else {
		throw err;
🧹 Nitpick comments (2)
scripts/auth.sh (1)

6-6: Declare and assign separately to avoid masking return values.

Combining declaration and assignment in a single statement with command substitution masks the return value of the command. If curl or jq fails, the function will still return success.

This is addressed by the suggested fix in the previous comment, which separates the curl response capture from the token extraction.

scripts/init.sh (1)

10-14: Declare and assign separately to avoid masking return values.

Lines 11-12 combine declaration and command substitution in single statements, which masks the return value. If curl fails despite retries, or if jq fails, the function will still succeed and potentially return an empty token.

Consider separating declaration from assignment:

 function get_token {
-  local response=$(curl --fail --retry 5 -X POST -H "Content-Type: application/json" -d '{"email": "'"$ADMIN_EMAIL"'", "password": "'"$ADMIN_PASSWORD"'"}' $DIRECTUS_URL/auth/login)
-  local token=$(echo "$response" | jq -r '.data.access_token')
+  local response
+  local token
+  response=$(curl --fail --retry 5 -X POST -H "Content-Type: application/json" -d '{"email": "'"$ADMIN_EMAIL"'", "password": "'"$ADMIN_PASSWORD"'"}' $DIRECTUS_URL/auth/login)
+  token=$(echo "$response" | jq -r '.data.access_token')
   echo "$token"
 }

This allows the script to catch curl/jq failures properly via set -e.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0544d62 and 62a0bfe.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • package.json (3 hunks)
  • scripts/auth.sh (1 hunks)
  • scripts/init.sh (3 hunks)
  • scripts/wait-for.sh (0 hunks)
  • test/e2e/global.setup.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • scripts/wait-for.sh
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{vue,ts,js}

⚙️ CodeRabbit configuration file

We use Nuxt with auto imports enabled. Don't warn about missing imports.

Files:

  • test/e2e/global.setup.ts
🧬 Code graph analysis (1)
scripts/auth.sh (1)
scripts/init.sh (1)
  • get_token (10-14)
🪛 Shellcheck (0.11.0)
scripts/auth.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 6-6: Declare and assign separately to avoid masking return values.

(SC2155)

scripts/init.sh

[warning] 11-11: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 12-12: Declare and assign separately to avoid masking return values.

(SC2155)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: Run e2e tests

@MartinKolarik MartinKolarik merged commit 9b2a779 into master Oct 16, 2025
5 checks passed
@MartinKolarik MartinKolarik deleted the wait-on branch October 16, 2025 11:20
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.

3 participants