Repository navigation
tsparser: report database usage outside services - #2604
Closed
marcuskohlberg wants to merge 2 commits into
Closed
marcuskohlberg wants to merge 2 commits into
marcuskohlberg wants to merge 2 commits into
Conversation
Using a database from code outside a service (e.g. SQLDatabase.named in a shared lib/ directory) built a ParseError but never reported it, so the usage was silently dropped. encore run and encore test give the process every database, so it worked locally, but deployed services only get the databases attributed to them, and every query failed with "this database is not configured for use by this process". Report the error, with a hint matching the Go parser's, as is already done for buckets, metrics and cache clusters.
Match the docs on sharing databases instead of the Go phrasing about passing a reference into a library.
marcuskohlberg
force-pushed
the
tsparser-report-unattributed-db-usage
branch
from
October 10, 2026 08:42
aea0088 to
1b8ddb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In TS apps, using a database from code outside a service works under
encore runandencore test, but fails once deployed, both on Encore Cloud and in self-hosted Docker images. Every query returns 500 withthis database is not configured for use by this process.Found while migrating Pingvin Share from NestJS to Encore:
lib/prisma.tsusedSQLDatabase.named("pingvin").connectionString.Repro
GET /countencore runencore build docker)this database is not configured for use by this processEncore Cloud repro app: deploy. Traces of the failed requests:
Calling the same query from inside
auth/returns 200 in the Docker image.Root cause
In
tsparser/src/legacymeta/mod.rs, a database usage outside any service built aParseErrorwith.parse_err(...)and dropped it, so the usage was silently ignored andauth.databasesended up empty in the metadata. Buckets, metrics and cache clusters use.err(...), which reports the error.That empty list only matters once deployed:
encore runconfigures every database for the process (cli/daemon/run/runtime_config2.go), so it works locally.encore build dockerkeeps only the databases in the hosted services'Service.Databasesand drops the rest from the infra config (cli/daemon/export/infra_config.go).Service.Databases, and only linked databases end up in the runtime config.Go apps aren't affected: the Go parser already rejects this with
Infrastructure resources can only be referenced within services(E1814).Fix
Report the error, with a hint on how to fix it.
encore run,encore testand builds now fail right away:Both documented ways of sharing a database keep working: declaring it in a shared module and referencing it from services, and
SQLDatabase.namedin another service. Only using the database from shared code is rejected.This is a breaking change for TS apps that use a database from shared code. Those apps only work locally today and fail when deployed, so failing early seems better. A follow-up could attribute shared-code usage to the importing services instead, so the pattern just works.
Testing
cargo test -p encore-tsparserpasses, and clippy is clean.Summary by CodeRabbit