Commit Graph

2762 Commits

Author SHA1 Message Date
BilalG1
ff370b615b
Merge branch 'external-db-sync' into external-db-sync-clickhouse-default 2026-02-04 18:30:58 -08:00
BilalG1
6b893706c8
cmd k query analytics (#1160)
https://www.loom.com/share/9e6b13061a314bcb94bc5cb7232c80fb
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->
2026-02-04 18:30:44 -08:00
Bilal Godil
98d451dd9d increase test timeout 2026-02-04 18:22:51 -08:00
Bilal Godil
362e1fb25a merge dev 2026-02-04 16:24:26 -08:00
Bilal Godil
8247481e49 test: disable direct external db sync in CI 2026-02-04 16:01:15 -08:00
Konstantin Wohlwend
7a3c55a709 Fix dev-perf-stats 2026-02-04 13:59:31 -08:00
Konstantin Wohlwend
988cc01e7a Mute some long request warnings 2026-02-04 13:50:38 -08:00
Konstantin Wohlwend
4abd410087 Various fixes 2026-02-04 13:30:49 -08:00
Konstantin Wohlwend
04970c25cb Update vercel.json 2026-02-04 12:32:52 -08:00
Bilal Godil
43c1f157d0 clickhouse user sync 2026-02-04 11:41:01 -08:00
Konstantin Wohlwend
6fcf1a888f Test sign-up rules widget 2026-02-04 11:22:42 -08:00
Konstantin Wohlwend
457ff2bdbe Quetzal translations 2026-02-04 10:19:59 -08:00
Konstantin Wohlwend
13c6088134 chore: update package versions 2026-02-04 10:01:04 -08:00
Bilal Godil
719d1c221d Merge remote-tracking branch 'origin/dev' into external-db-sync 2026-02-04 09:15:58 -08:00
Bilal Godil
7fd7886dc6 fix sot test 2026-02-04 09:15:51 -08:00
Madison
5b811fa012
[Docs] fix broken requests on API playground (#1125)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* API error responses now include richer metadata (URL, HTTP method, and
inferred error type).
* Error panels show an error type badge (when known) and request
duration for failed calls.
* POST/PUT/PATCH requests consistently send JSON bodies and include
Content-Type headers, even when empty.
* Code examples (curl/JS/Python) updated to reflect consistent body and
header handling.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-04 09:42:57 -06:00
Aman Ganapathy
bb69ee4230
[Fix] Token Store Overrides are now Respected (#1156)
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migrations are backwards-compatible / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test With Custom Base Port / restart-dev-and-test-with-custom-base-port (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests with custom base port / setup-tests-with-custom-base-port (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
DB migrations are backwards-compatible / Test migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migrations are backwards-compatible / No migration changes (skipped) (push) Has been cancelled
### Context
Recently, a user raised [this
issue](https://github.com/stack-auth/stack-auth/issues/1144), which
indicated that `tokenOverrides` were not being respected/used in the
`getUser()` function. If we trace the flow through this function, we see
`this._getSession -> this._getOrCreateTokenStore -> _createCookieHelper
-> createCookieHelper -> createNextCookieHelper -> await rscHeaders()`.
What this means is that even when a `requestLike tokenOverride` was
passed, we would not end up using it because the `createCookieHelper`
call occurs before the extant override checking logic in
`getOrCreateTokenStore`, and the `createCookieHelper` didn't check the
override but only the default `tokenStoreInit`. This caused the error to
propagate up.

### Summary of Changes
We check the `tokenStoreOverride` in the `createCookieHelper` function
now, preventing this issue from happening. We also add extra test
coverage to verify that overrides are respected, and don't overwrite the
default token store.

### Out of Scope Discussion
The original issue was raised with a `bun` runtime running `next.js`
code. There seems to be some incompatibility between `bun 1.3.8` and
`nextjs 15+`, not just with our backend but with fetching and working
with responses from any `nextjs` server.
2026-02-03 18:58:46 -08:00
Bilal Godil
64d9d93f49 remove old tests
Some checks failed
DB migrations are backwards-compatible / Check if migrations changed (push) Has been cancelled
DB migrations are backwards-compatible / Test migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migrations are backwards-compatible / No migration changes (skipped) (push) Has been cancelled
2026-02-03 18:35:31 -08:00
Bilal Godil
c91998ef73 add tracing 2026-02-03 18:13:19 -08:00
Bilal Godil
d34a2c7fa4 fusebox 2026-02-03 17:53:36 -08:00
Bilal Godil
c0a3f7af6d replace trigger 2026-02-03 17:20:10 -08:00
Bilal Godil
3b9c22e175 merge dev 2026-02-03 16:39:35 -08:00
Bilal Godil
8e9220505d fix routes, external-db dashboard 2026-02-03 16:38:46 -08:00
BilalG1
bbac70e4bf
Merge branch 'dev' into external-db-sync 2026-02-03 13:27:25 -08:00
Bilal Godil
61f2b79f46 Merge branch 'external-db-sync' of https://github.com/stack-auth/stack-auth into external-db-sync 2026-02-03 11:35:58 -08:00
Bilal Godil
d04e944f8d concurrent fix 2026-02-03 11:35:52 -08:00
BilalG1
3370e637f1
test fixes (#1155)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->
2026-02-03 11:22:28 -08:00
Konsti Wohlwend
7a35751f8e
Sign up rules (#1138)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> **High Risk**
> Touches core sign-up/auth flows and user restriction semantics
(including new DB constraints) and introduces dynamic rule
evaluation/logging; misconfiguration or CEL/parser bugs could block
sign-ups or incorrectly restrict users.
> 
> **Overview**
> Introduces **CEL-based sign-up rules** (config-driven) that are
evaluated during password/OTP/OAuth sign-ups and anonymous upgrades;
matching rules can reject sign-ups or mark users as admin-restricted,
and triggers are logged for analytics.
> 
> Extends `ProjectUser` with `restrictedByAdmin` plus public/private
restriction details, updates restriction computation/filtering, and
exposes these fields via user CRUD (including validation + DB constraint
enforcing consistency when unrestricted).
> 
> Adds a new dashboard **Sign-up Rules** page with a visual condition
builder (CEL <-> visual tree), drag-reorder by priority, per-rule 48h
sparkline analytics via a new hidden internal endpoint, and adds
user-page UI to view/edit manual restrictions. Also refactors ClickHouse
client initialization to require env vars (removing
`isClickhouseConfigured` checks) and adjusts CI container startup wait
time.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2141e689e8c1b72303b805e9234f996010d0880. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Sign-up Rules: visual rule builder, in-project CRUD with drag-reorder,
per-rule analytics, backend evaluation, and admin UI.
* Admin user restrictions: dashboard controls, banners/status,
public/private admin details surfaced in user views.

* **APIs & Schema**
* Config and user schemas extended; new SignUpRejected error and sign-up
rule types added.

* **Tests**
* Extensive unit and E2E coverage for rules, parser, evaluator,
analytics, and restricted-user flows.

* **Docs**
  * Editorial guidance added to AGENTS.md.

* **Chores**
* DB statement timeout, updated clean script, minor dependency
additions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-03 11:08:24 -08:00
BilalG1
1038d1ab2c
Merge branch 'dev' into external-db-sync 2026-02-03 10:20:17 -08:00
Konstantin Wohlwend
13cd1f0f2b chore: update package versions
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Mirror main branch to main-mirror-for-wdb / lint_and_build (push) Has been cancelled
Publish npm packages / publish (push) Has been cancelled
Dev Environment Test With Custom Base Port / restart-dev-and-test-with-custom-base-port (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests with custom base port / setup-tests-with-custom-base-port (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
Publish Swift SDK to prerelease repo / publish (push) Has been cancelled
Sync Main to Dev / sync-commits (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
2026-02-03 10:06:48 -08:00
Konstantin Wohlwend
ebc8fc1f4e Fix tests 2026-02-03 10:02:02 -08:00
Konstantin Wohlwend
097c0310c4 Check all users when verifying data integrity 2026-02-03 10:00:30 -08:00
Bilal Godil
62171dc231 single test run 2026-02-03 09:44:14 -08:00
Konstantin Wohlwend
abc8daf9cb Tracing for email health endpoint 2026-02-03 09:25:27 -08:00
Bilal Godil
8910138be9 fixes 2026-02-03 09:19:58 -08:00
BilalG1
686a1e6d2f
Merge branch 'dev' into external-db-sync 2026-02-02 18:33:17 -08:00
BilalG1
5192875e42
CI: run dev tests single-worker (#1153)
Runs dev-focused CI test suites with a single Vitest worker to reduce
load and avoid external DB sync timeouts.
2026-02-02 18:32:55 -08:00
Aman Ganapathy
9002b63f7a
[Fix] Fix Various bugs on the Explore Apps Page (#1142)
### Context

There are a smattering of bugs on the explore apps page. Clicking
"Enable App" may enable the app, but the button still shows, plus it
causes unnecessary redirects while the modal is still up. This behavior
can be seen in the linked clip


https://github.com/user-attachments/assets/09b12ccf-e174-4289-91f3-4f0e73cfe7e4

### Summary of Changes

We dynamically handle the modal open state, and track the path updates.
This lets us deal with the bugs above while avoiding unnecessary
renders, allowing reopening of previously opened modals, and preventing
unnecessary redirects.
Dealing with the enable apps button issues also now allows users to
navigate to the app page from the explore apps modal.

We also add a disable button to the modal. Previously, users had to
check the options for each app in order to disable it. Now they can do
it on the modal itself, which is in line with how the "Enable App"
functionality works.

### UI Demo




https://github.com/user-attachments/assets/5bfd35c6-5d28-4f99-958a-9300533e2351
2026-02-02 17:36:26 -08:00
Aman Ganapathy
abc320b4db
[Refactor] [Fix] Email Rendering Pipeline Refactor, Error Handling, and Bug Fixes (#1140)
### Context
We noticed some errors pop up on sentry related to email rendering.
These errors seem to have been triggered by the same issue, and could be
categorized as follows:

1. Sanity test mismatch, even when the errors from freestyle and vercel
sandbox were broadly similar. This occurred due to stack traces
differing in different execution environments.
2. Rendering errors from freestyle and vercel sandbox caused by the
theme not being imported/ empty theme component.

Upon investigation, this occurred because hitting save on the email
themes page with an invalid theme (ex: deleting the `export` keyword, or
renaming the `EmailTheme` component) still triggers `bundleAndExecute`
with the invalid themes. This will obviously fail and cause the errors
to be logged, however there is no cause for concern here because the
error is returned and the save is denied because an error is returned.
It's more of a matter of noisy error logs and too strict sanity test
comparisons.

Beyond that, `js-execution` is a little opaque and hard to understand,
and this can mask errors in logic.

We also noticed a new issue: manually throwing an error in the email
theme code editor, and then trying to save was actually successful. This
was because the version of `react-email/components` we were using had
faulty error handling, and fell back to client side rendering, masking
the error. This wasn't caught by our `try-catch` safeguards because it
was a render time issue that was masked. More specifically, this was
what `react-email` was doing: `Switched to client rendering because the
server rendering errored`.

### Summary of Changes

We loosen the sanity test comparison between engine execution results in
case of errors. We then refactor the `js-execution` and
`email-rendering` files to read better, and to only `captureError` when
a service is down, but not for runtime errors in the user submitted
code.

To deal with the other bug, we bumped `react-email/components` to the
latest version. However, doing so exposed a gap between real `freestyle`
and our `freestyle-mock`: with the mock, the errors that were now raised
were treated as uncaught exceptions, crashing the mock server.
Consequently, we switched to using `node` over `bun`.

We also expanded test coverage to account for different error paths. 

Co-authored-by: Konstantin Wohlwend <n2d4xc@gmail.com>
2026-02-02 17:35:51 -08:00
BilalG1
093eaf08f6
e2e: isolate external DB sync cleanup per suite (#1148)
Possible CI flake fix: track external DB sync cleanup per test suite to
avoid cross-suite config resets.\n\n- Lint: pass\n- Typecheck: pass

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added external database synchronization, enabling data replication
from the internal database to external PostgreSQL databases with
incremental batching and sequence tracking.
  * Introduced background cron job execution system for scheduled tasks.

* **Tests**
* Added comprehensive test suites for external database synchronization
scenarios including basic operations, advanced configurations,
high-volume data transfers, and race condition handling.

* **Chores**
* Enhanced CI/CD workflows to support external database sync operations.
* Updated Docker configuration and environment variables for improved
testing infrastructure.

* **Bug Fixes**
* Increased test timeout threshold for session expiration tests to
accommodate slower executions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-02 16:09:28 -08:00
BilalG1
31b8d8040d
query timing route (#1146)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added a dedicated endpoint to retrieve query timing statistics using
query identifiers.
* Query responses now include a unique query_id for tracking and
reference.

* **Improvements**
  * Query timeout validation now enforces a maximum limit of 2 minutes.
* Query response structure updated to support separate timing
information retrieval.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-02 16:07:59 -08:00
BilalG1
0f6ae49cd8
account payments tab fix (#1147) 2026-02-02 15:22:19 -08:00
Bilal Godil
ba1df26792 fix tests 2026-02-02 13:57:57 -08:00
BilalG1
e5cbc1af54
Merge branch 'dev' into external-db-sync 2026-02-02 13:21:15 -08:00
Konstantin Wohlwend
0f8b23dda1 Reduce error flickering 2026-02-02 13:07:45 -08:00
Bilal Godil
2e0d8de3dc m 2026-02-02 12:53:54 -08:00
Bilal Godil
b841f7b2f0 fix tests 2026-02-02 12:20:40 -08:00
Bilal Godil
b5781a146d Merge remote-tracking branch 'origin/dev' into external-db-sync 2026-02-02 10:57:38 -08:00
Konstantin Wohlwend
ab99302257 Fix lint 2026-02-02 10:48:39 -08:00
Madison
2227f75e41 CHANGELOG.md Update with Images 2026-02-02 11:27:09 -06:00