BuilderIO / BuilderIO/agent-native

Files system database offers a New page control it cannot honor

Open Beginner friendly
#4,915 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
449
Avg merge
10h 24m
Merged PRs (30d)
883

Description

# Content: the Files system database offers "New page" and then reports a failure

**Version:** `@agent-native/core` 0.178.1, Content template (`templates/content`)
installed as `apps/documents` in a four-app workspace on Vercel with Neon
Postgres.

**What happens.** Create a new workspace in Content. Its default view is the
Files database, at `/page/content_document_files_?databaseViewId=default`.
The table renders a "New page" control. Clicking it shows the error toast
"Failed to create row". No row is created, and nothing is wrong with the
database.

**Why.** The server deliberately withholds the mutation contract for any
database that carries a system role. In `actions/_database-utils.ts:1241`:

```ts
const mutationContract =
page.databaseRecord.spaceId && !page.databaseRecord.systemRole
? await getDatabaseMutationContract(/* ... */)
: undefined;
```

The Files database is exactly such a database: `contentDatabases.systemRole` is
`"files"` (`server/db/schema.ts:267`, and the role is matched by name
throughout `actions/_files-system-properties.ts`, for example line 136 and line
263). Its rows come from uploads, not from manual creation, so withholding the
contract is correct.

The client does not treat that as "this table cannot take manual rows". In
`app/components/editor/database/DatabaseView.tsx:1905-1910`:

```ts
const mutationContract = data?.mutationContract;
if (!mutationContract) {
toast.error(dbText("failedToCreateRow"));
return null;
}
```

A missing contract, which is a stable property of the view, is reported with
the same message used for a mutation that actually failed. The function returns
before any request is made, which is why server logs for the session show no
failing call: the create was never attempted.

Note that the same component already has a silent, correct branch one line
earlier for a related case, `if (isWorkspaceCatalog) return null;`
(`DatabaseView.tsx:1904`). System-role databases are not covered by it.

**Evidence.** Production runtime logs for the session in which the toast
appeared contain no row-creation request of any kind, while the surrounding
`get-content-database`, `collab` and `application-state` traffic for the same
document id is present. That is consistent with the early return above and
inconsistent with a server-side failure.

**Expected.** Either the control is not offered for a database whose
`mutationContract` is absent, which matches how `isWorkspaceCatalog` is already
handled, or the message says what is true: rows in the Files database come from
uploads. The smaller change is extending the existing early-return branch to
cover a missing mutation contract, since the component already reads
`data?.mutationContract` at that point.

**Impact.** Every new workspace lands the user on the Files view, so this is
the first table many users meet, and its primary control reports a failure that
did not happen. The affordance and the contract disagree, and the message sends
the reader looking for a broken database.

**Workaround.** None that does not fork the template. All three files in the
trace, `DatabaseView.tsx`, `_database-utils.ts` and `_files-system-properties.ts`,
are byte-identical to the shipped template in this workspace, verified by diff
against the version-matched corpus copy. Users create pages from the sidebar
instead.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in app/components/editor/database/DatabaseView.tsx around lines 1904-1910 and compare the existing isWorkspaceCatalog early return with the missing mutationContract case. Review actions/_database-utils.ts:1241 and server/db/schema.ts:267 for the contract and Files system-role behavior. Done means the Files view no longer offers or misleadingly reports a manual-row creation failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
backend, databases, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.