Skip to content

[Feat] new scripts on migrate/seed/init run for internal#1421

Open
nams1570 wants to merge 1 commit intodevfrom
migrate-plans-and-products-ui
Open

[Feat] new scripts on migrate/seed/init run for internal#1421
nams1570 wants to merge 1 commit intodevfrom
migrate-plans-and-products-ui

Conversation

@nams1570
Copy link
Copy Markdown
Collaborator

@nams1570 nams1570 commented May 7, 2026

Context

One script grants free plan to any team which is a customer of the internal project who doesnt have it already.
We also want to allow for users to be able to migrate teams to latest version of their product.

Needed because some subs on dev right now dont have a plan. And internal isnt using latest version of its own growth plan.

Describing the Paths we want to Account for

  1. Users on production who currently don't have a plan should get free plans, since this script is run with every migrate
  2. Users on production should get the latest version of each plan of ours. So a forced migration to latest version of internal project plans
  3. No other project's products/product lines should be affected. They will continue to have product versioning
  4. 2 should apply to test mode subscriptions as well, on top of stripe subscriptions. All of them should be refreshed
  5. Internal project itself should get latest version of its own growth plan
  6. If the bulldozer write fails, we should be able to recover on next migration (this should already be handled by init bulldozer script, because it checks if prisma db and bulldozer db are out of sync)
  7. if the regenerate or backfill fail, we should be able to recover just by rerunning the script
  8. Product version table should not balloon. No table should really balloon

Summary by CodeRabbit

  • New Features

    • Added automated backfill capability to grant internal free plans to qualifying billing teams during database initialization.
  • Chores

    • Enhanced database initialization process to include free plan provisioning alongside standard setup steps.
    • Added new database management scripts for free plan backfill operations.

Copilot AI review requested due to automatic review settings May 7, 2026 02:50
@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-auth-hosted-components Ready Ready Preview, Comment May 7, 2026 7:13pm
stack-backend Ready Ready Preview, Comment May 7, 2026 7:13pm
stack-dashboard Ready Ready Preview, Comment May 7, 2026 7:13pm
stack-demo Ready Ready Preview, Comment May 7, 2026 7:13pm
stack-docs Ready Ready Preview, Comment May 7, 2026 7:13pm
stack-preview-backend Ready Ready Preview, Comment May 7, 2026 7:13pm
stack-preview-dashboard Ready Ready Preview, Comment May 7, 2026 7:13pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a deploy-time backfill script that automatically grants the internal free plan to all qualifying billing teams in Stack Auth's internal tenancy. It changes ensureFreePlanForBillingTeam to return a boolean indicating whether a new subscription was created, integrates the backfill into database migrations and npm scripts, and updates tests to verify the new return semantics.

Changes

Internal Free Plan Backfill

Layer / File(s) Summary
Return Type Contract
apps/backend/src/lib/payments/ensure-free-plan.ts
ensureFreePlanForBillingTeam changes from Promise<void> to Promise<boolean>, returning true only when a new free subscription is created and false for misconfigured products, already-occupied product lines, race losses, or serialization failures.
Backfill Script Implementation
apps/backend/scripts/backfill-internal-free-plans.ts
New runBackfillInternalFreePlans() function resolves internal tenancy, validates free product configuration, iterates billing teams via keyset pagination in fixed batches, calls ensureFreePlanForBillingTeam per team with isolated error handling, logs progress every 100 teams, and returns { granted, failed, total } counters.
Migration CLI and Script Integration
apps/backend/scripts/db-migrations.ts
Imports runBackfillInternalFreePlans, adds new backfill-internal-free-plans CLI command with help documentation, integrates into reset command flow via runBulldozerPaymentsInit(), and implements command handler.
NPM Script Wiring
apps/backend/package.json, package.json
Adds db:backfill-internal-free-plans script to backend package, updates root start-deps:no-delay to execute backfill after db:init, and delegates via root script.
Test Updates
apps/backend/src/lib/payments/ensure-free-plan.test.ts
Tests now assert boolean return values: fast path and occupied cases return false, slow path returns true, idempotent calls return true then false, and edge cases verify correct semantics while maintaining subscription state assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hoppy script, bounded and bright,
Grants free plans through the night,
Team by team, no rush in sight,
Pagination keeps memory right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title refers to new scripts that run during migrate/seed/init for internal, which aligns with the actual changes adding backfill scripts and integrating them into the db-migrations workflow.
Description check ✅ Passed The description comprehensively explains the context, paths accounted for, and requirements, demonstrating clear understanding of the changes and their implications for plan management.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate-plans-and-products-ui

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds deploy-time/internal maintenance scripts to ensure Internal tenancy billing teams always have a baseline free subscription and that existing internal subscriptions’ product snapshots (and Stripe metadata pointers for Stripe-backed subs) are refreshed to the latest product config. It wires these scripts into the backend DB lifecycle commands so dev/prod environments converge on consistent billing state.

Changes:

  • Add backfill-internal-free-plans.ts to grant the free plan to orphaned internal billing teams, and run it on db-migrations reset/seed/init/migrate.
  • Add regen-internal-subscriptions-to-latest.ts to rebase internal subscriptions onto the latest product snapshot (and Stripe metadata productVersionId where applicable), and run it on the same DB lifecycle commands.
  • Update ensureFreePlanForBillingTeam to return a boolean indicating whether it actually inserted a new free-plan subscription row, and expand real-DB test coverage for both scripts.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
apps/backend/src/scripts/regen-internal-subscriptions-to-latest.test.ts Adds real-DB tests covering snapshot regeneration, Stripe-metadata rebasing behavior, failure isolation, and Bulldozer downstream effects.
apps/backend/src/lib/payments/ensure-free-plan.ts Changes ensureFreePlanForBillingTeam to return boolean and documents return semantics for deploy-time backfills.
apps/backend/src/lib/payments/ensure-free-plan.test.ts Updates tests to assert the new boolean return value and adds a regression test for ended-only subscriptions.
apps/backend/scripts/regen-internal-subscriptions-to-latest.ts Introduces the internal subscription regeneration script (DB snapshot + Stripe metadata rebase + ProductVersion upsert).
apps/backend/scripts/db-migrations.ts Runs the new internal-tenancy backfills during reset/seed/init/migrate flows (after Bulldozer init).
apps/backend/scripts/backfill-internal-free-plans.ts Introduces the internal free-plan backfill script with keyset pagination and per-team failure isolation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/backend/scripts/regen-internal-subscriptions-to-latest.ts Outdated
Comment thread apps/backend/scripts/regen-internal-subscriptions-to-latest.ts Outdated
Comment thread apps/backend/scripts/regen-internal-subscriptions-to-latest.ts Outdated
Comment thread apps/backend/scripts/regen-internal-subscriptions-to-latest.ts Outdated
Comment thread apps/backend/scripts/regen-internal-subscriptions-to-latest.ts Outdated
Comment thread apps/backend/scripts/backfill-internal-free-plans.ts
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR adds two deploy-time idempotent scripts — backfill-internal-free-plans and regen-internal-subscriptions-to-latest — and wires them into every migration entry point (reset, seed, init, migrate). It also updates ensureFreePlanForBillingTeam to return boolean so the backfill can report accurate grant counts.

  • backfill-internal-free-plans.ts: pages over all billing teams in the internal tenancy via keyset pagination, calls ensureFreePlanForBillingTeam per team, and isolates per-team failures so a single DB blip doesn't block the rest of the run.
  • regen-internal-subscriptions-to-latest.ts: for every active subscription, compares the stored JSON snapshot and the Stripe metadata version pointer against the current plan config and rewrites whichever is stale. Stripe metadata is written first so a subsequent webhook self-heals any partial failure where Prisma commits but Bulldozer doesn't.
  • db-migrations.ts: adds both scripts after runBulldozerPaymentsInit in all relevant cases, including adding runBulldozerPaymentsInit to the reset case where it was previously absent.

Confidence Score: 5/5

Safe to merge; both scripts are idempotent, failures are isolated per-team/sub, and all migration entry points get the correct ordering.

The dual-write ordering (Stripe first, then Prisma+Bulldozer) is correct and self-healing. The retry path after a partial Bulldozer failure works because getSubscriptionMapForCustomer reads from Bulldozer, so a stale Bulldozer row causes the DB branch to re-enter on the next run. Fail-fast misconfiguration checks and comprehensive integration tests covering all code paths give high confidence.

No files require special attention.

Important Files Changed

Filename Overview
apps/backend/scripts/backfill-internal-free-plans.ts New script that pages over all internal billing teams and grants the free plan to any without one; keyset pagination, per-team error isolation, and a fail-fast misconfiguration check are all correct.
apps/backend/scripts/regen-internal-subscriptions-to-latest.ts New script that resyncs every active internal subscription's DB snapshot and Stripe metadata pointer to the latest plan version; dual-write ordering (Stripe first, then Prisma + Bulldozer) ensures correct self-healing on partial failures, and the retry logic is sound because subMap is read from Bulldozer.
apps/backend/scripts/db-migrations.ts Wires both new scripts into all relevant migration cases (reset, seed, init, migrate); runBulldozerPaymentsInit is correctly placed before the backfills in the reset case where it was previously absent.
apps/backend/src/lib/payments/ensure-free-plan.ts Return type changed from void to boolean so callers can distinguish an actual grant from a no-op; all return paths now return an explicit boolean value.
apps/backend/src/lib/payments/ensure-free-plan.test.ts Tests updated to assert the new boolean return value and adds a regression test for teams whose only subscription is ended (verifying the endedAt-aware occupancy predicate).
apps/backend/src/scripts/regen-internal-subscriptions-to-latest.test.ts New integration test file covering all regen paths: stale vs fresh snapshots, Stripe-backed vs in-product subs, per-sub failure isolation, missing product-id skipping, ended-sub skipping, and end-to-end Bulldozer queue propagation.

Sequence Diagram

sequenceDiagram
    participant M as db-migrations.ts
    participant B as runBulldozerPaymentsInit
    participant FP as runBackfillInternalFreePlans
    participant RG as runRegenInternalSubscriptionsToLatest
    participant DB as Prisma/Postgres
    participant BUL as Bulldozer
    participant STR as Stripe API

    M->>B: await runBulldozerPaymentsInit
    B-->>M: done
    M->>FP: await runBackfillInternalFreePlans
    loop per team
        FP->>BUL: getSubscriptionMapForCustomer
        alt no occupying sub
            FP->>DB: retryTransaction(SERIALIZABLE)
            FP->>BUL: bulldozerWriteSubscription
        end
    end
    FP-->>M: granted/failed/total
    M->>RG: await runRegenInternalSubscriptionsToLatest
    loop per team per sub
        RG->>BUL: getSubscriptionMapForCustomer
        alt stale Stripe pointer
            RG->>STR: subscriptions.update
        end
        alt stale DB snapshot
            RG->>DB: retryTransaction
            RG->>BUL: bulldozerWriteSubscription
        end
    end
    RG-->>M: Counters
Loading

Reviews (2): Last reviewed commit: "feat: new scripts on migrate/seed/init r..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (2)
apps/backend/scripts/db-migrations.ts (1)

207-245: 💤 Low value

Sequencing and idempotency rationale are well-documented.

Order (Bulldozer init → free-plan backfill → regen) is correct given the stated dependencies (regen dual-writes into stored tables; free-plan backfill reads the Subscription LFold). Both helpers are documented as idempotent so running on every deploy and every dev DB lifecycle is safe.

Minor optional thought: the same trio runBulldozerPaymentsInit / runBackfillInternalFreePlans / runRegenInternalSubscriptionsToLatest is repeated verbatim in 4 branches. A small runPostMigrationInternalSetup() helper would deduplicate and ensure future steps stay in lockstep across branches — but the explicitness has its own value, so deferable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/backend/scripts/db-migrations.ts` around lines 207 - 245, The repeated
trio of calls runBulldozerPaymentsInit(globalPrismaClient),
runBackfillInternalFreePlans(), and runRegenInternalSubscriptionsToLatest()
should be extracted into a single helper (e.g., runPostMigrationInternalSetup)
to remove duplication and keep future changes in one place; create a function
runPostMigrationInternalSetup that invokes those three helpers (accepting any
needed args like globalPrismaClient) and replace the verbatim calls in the
branches ('generate-migration-file', 'seed', 'init', 'migrate' and the earlier
default/init branch) with a single await runPostMigrationInternalSetup(...)
call.
apps/backend/src/scripts/regen-internal-subscriptions-to-latest.test.ts (1)

225-225: ⚡ Quick win

Replace Object.keys(...)[0]! with ?? throwErr(...) per coding guidelines.

Lines 225, 310, 412, and 462 all use the Object.keys(growth.includedItems)[0]! pattern. If growth ever ships without includedItems (config drift, future seed change, etc.), withoutItem(growth, undefined) would no-op and the test would silently pass on a non-stale snapshot rather than flagging the violated precondition.

♻️ Suggested refactor (illustrative)
-    const stale = withoutItem(growth, Object.keys(growth.includedItems)[0]!);
+    const someItemId = Object.keys(growth.includedItems)[0]
+      ?? throwErr("growth has no includedItems to drop");
+    const stale = withoutItem(growth, someItemId);

Apply at lines 225, 310, 412, and 462. Line 154 already extracts someItemId via an explicit length === 0 throw — that pattern is preferred here too.

As per coding guidelines: "Code defensively and prefer ?? throwErr(...) over non-null assertions, with explicit error messages stating the violated assumption".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/backend/src/scripts/regen-internal-subscriptions-to-latest.test.ts` at
line 225, Replace the non-null assertion usage
Object.keys(growth.includedItems)[0]! with a defensive null-check that throws
when the assumption is violated: obtain the first key from
Object.keys(growth.includedItems) and if it is undefined call throwErr(...) with
a clear message (e.g., "expected growth.includedItems to contain at least one
item") before passing it to withoutItem; apply this change for each occurrence
that uses Object.keys(growth.includedItems)[0]! (the call sites around
withoutItem and any related test setup) so tests will fail fast on missing
includedItems instead of silently no-oping.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/backend/scripts/db-migrations.ts`:
- Around line 207-245: The repeated trio of calls
runBulldozerPaymentsInit(globalPrismaClient), runBackfillInternalFreePlans(),
and runRegenInternalSubscriptionsToLatest() should be extracted into a single
helper (e.g., runPostMigrationInternalSetup) to remove duplication and keep
future changes in one place; create a function runPostMigrationInternalSetup
that invokes those three helpers (accepting any needed args like
globalPrismaClient) and replace the verbatim calls in the branches
('generate-migration-file', 'seed', 'init', 'migrate' and the earlier
default/init branch) with a single await runPostMigrationInternalSetup(...)
call.

In `@apps/backend/src/scripts/regen-internal-subscriptions-to-latest.test.ts`:
- Line 225: Replace the non-null assertion usage
Object.keys(growth.includedItems)[0]! with a defensive null-check that throws
when the assumption is violated: obtain the first key from
Object.keys(growth.includedItems) and if it is undefined call throwErr(...) with
a clear message (e.g., "expected growth.includedItems to contain at least one
item") before passing it to withoutItem; apply this change for each occurrence
that uses Object.keys(growth.includedItems)[0]! (the call sites around
withoutItem and any related test setup) so tests will fail fast on missing
includedItems instead of silently no-oping.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 039860b7-acba-44d0-8a07-864abff8843e

📥 Commits

Reviewing files that changed from the base of the PR and between d69773c and bc1883f.

📒 Files selected for processing (6)
  • apps/backend/scripts/backfill-internal-free-plans.ts
  • apps/backend/scripts/db-migrations.ts
  • apps/backend/scripts/regen-internal-subscriptions-to-latest.ts
  • apps/backend/src/lib/payments/ensure-free-plan.test.ts
  • apps/backend/src/lib/payments/ensure-free-plan.ts
  • apps/backend/src/scripts/regen-internal-subscriptions-to-latest.test.ts

Copy link
Copy Markdown
Contributor

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/backend/scripts/backfill-internal-free-plans.ts`:
- Around line 95-99: The loop currently awaits each
ensureFreePlanForBillingTeam(teamId) sequentially which slows large backfills;
change to a bounded-concurrency pattern (small worker pool) so multiple teamIds
are processed in parallel while limiting DB pressure: use iterateInternalTeamIds
to produce IDs and dispatch ensureFreePlanForBillingTeam(teamId) into a
concurrency limiter (e.g., p-limit or a simple semaphore) sized to a small
constant (e.g., 5–20), await all inflight promises before finishing each batch,
and preserve/error-handle incrementing total and granted counters inside each
task; keep TEAM_BATCH_SIZE for outer batching if desired.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 809a0dc1-fe89-4cae-b273-28fc16a747a2

📥 Commits

Reviewing files that changed from the base of the PR and between bc1883f and 28ad379.

📒 Files selected for processing (6)
  • apps/backend/scripts/backfill-internal-free-plans.ts
  • apps/backend/scripts/db-migrations.ts
  • apps/backend/scripts/regen-internal-subscriptions-to-latest.ts
  • apps/backend/src/lib/payments/ensure-free-plan.test.ts
  • apps/backend/src/lib/payments/ensure-free-plan.ts
  • apps/backend/src/scripts/regen-internal-subscriptions-to-latest.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/backend/src/lib/payments/ensure-free-plan.test.ts
  • apps/backend/scripts/db-migrations.ts
  • apps/backend/src/scripts/regen-internal-subscriptions-to-latest.test.ts
  • apps/backend/scripts/regen-internal-subscriptions-to-latest.ts

Comment thread apps/backend/scripts/backfill-internal-free-plans.ts
@nams1570
Copy link
Copy Markdown
Collaborator Author

nams1570 commented May 7, 2026

@greptileai please rereview, and read the updated PR description

This gives every team on internal proj w/o a plan the free plan.
It is idempotent - only gives a plan if team has no other plans in the pricing plans product line.
Copy link
Copy Markdown
Contributor

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Line 39: The package.json script "start-deps:no-delay" contains a stray
trailing "n" after the closing quote in the echo command, causing the printed
message to end with "n"; open the "start-deps:no-delay" script and remove the
extraneous trailing "n" so the echo argument ends with the closing quote only
(i.e., ensure the echo string is "\\nDependencies started... 'pnpm run
stop-deps' to stop them" with no characters after the final quote).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 378403af-9aba-4bd2-9924-c53d116b7a9b

📥 Commits

Reviewing files that changed from the base of the PR and between 28ad379 and ca2d729.

📒 Files selected for processing (6)
  • apps/backend/package.json
  • apps/backend/scripts/backfill-internal-free-plans.ts
  • apps/backend/scripts/db-migrations.ts
  • apps/backend/src/lib/payments/ensure-free-plan.test.ts
  • apps/backend/src/lib/payments/ensure-free-plan.ts
  • package.json
✅ Files skipped from review due to trivial changes (2)
  • apps/backend/package.json
  • apps/backend/src/lib/payments/ensure-free-plan.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/backend/scripts/backfill-internal-free-plans.ts
  • apps/backend/src/lib/payments/ensure-free-plan.test.ts
  • apps/backend/scripts/db-migrations.ts

Comment thread package.json
"wait-until-postgres-is-ready": "command -v pg_isready >/dev/null 2>&1 && pnpm run wait-until-postgres-is-ready:pg_isready || sleep 10 # not everyone has pg_isready installed, so we fallback to sleeping",
"wait-until-clickhouse-is-ready": "pnpm exec wait-on http://localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}36/ping",
"start-deps:no-delay": "pnpm pre && pnpm run deps-compose up --detach --build && pnpm run wait-until-postgres-is-ready && pnpm run wait-until-clickhouse-is-ready && pnpm run db:init && echo \"\\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them\"n",
"start-deps:no-delay": "pnpm pre && pnpm run deps-compose up --detach --build && pnpm run wait-until-postgres-is-ready && pnpm run wait-until-clickhouse-is-ready && pnpm run db:init && pnpm run db:backfill-internal-free-plans && echo \"\\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them\"n",
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Stray n outside the closing quote in the echo command.

After JSON-unescaping, the shell sees:

echo "\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them"n

Bash performs adjacent-token concatenation, so echo receives a single argument ending in ...stop themn, which prints as ...stop themn instead of the intended message. The n is a leftover fragment of a \n escape.

🐛 Proposed fix
-    "start-deps:no-delay": "pnpm pre && pnpm run deps-compose up --detach --build && pnpm run wait-until-postgres-is-ready && pnpm run wait-until-clickhouse-is-ready && pnpm run db:init && pnpm run db:backfill-internal-free-plans && echo \"\\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them\"n",
+    "start-deps:no-delay": "pnpm pre && pnpm run deps-compose up --detach --build && pnpm run wait-until-postgres-is-ready && pnpm run wait-until-clickhouse-is-ready && pnpm run db:init && pnpm run db:backfill-internal-free-plans && echo \"\\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them\"",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` at line 39, The package.json script "start-deps:no-delay"
contains a stray trailing "n" after the closing quote in the echo command,
causing the printed message to end with "n"; open the "start-deps:no-delay"
script and remove the extraneous trailing "n" so the echo argument ends with the
closing quote only (i.e., ensure the echo string is "\\nDependencies started...
'pnpm run stop-deps' to stop them" with no characters after the final quote).

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