#10568·nocobase

[Bug] Relation fields created in modern UI are missing from block field lists due to invalid `source` metadata

Author: xDemonMECreated Sep 30, 2026Updated Sep 30, 2026

* Describe the bug

Many-to-one fields created through the modern collection editor are saved successfully but do not appear in the field lists when configuring UI blocks.

The fields exist in persisted collection metadata returned by collections:get, but are missing from collections:listMeta, which the modern UI uses to load collection definitions.

The modern FieldForm automatically sets source to the current collection name:

set(values, 'source', props.collection.name);

However, the backend Collection.setField interprets source as a reference in the format collection.field. When it receives only a collection name, it looks for an undefined source field and skips loading the relation.

This was observed for two independently created m2o fields. Reloading the browser, clearing the cache, and restarting the container did not resolve the issue.

Setting source to null through the Data Modeling API restored both fields in collections:listMeta, while preserving their relation keys.

* Environment

  • NocoBase version: 2.2.19

  • Database type and version: PostgreSQL 16.14

  • OS: Linux Docker environment; host distribution not recorded

  • Deployment Methods: Docker

  • Docker image version: nocobase/nocobase:latest-full; installed NocoBase version 2.2.19

* How To Reproduce

  1. Open the collection editor in the modern UI.

  2. Create a general collection, for example tasks.

  3. Add a scalar foreign-key field actor_id compatible with users.id.

  4. Through the collection editor, add a many-to-one field:

    • Field name: actor
    • Target collection: users
    • Foreign key: actor_id
    • Target key: id
  5. Save the field.

  6. Create or open a table block using tasks.

  7. Open the field configuration list. The actor relation is missing.

  8. Inspect the saved collection definition using collections:get with appends=fields. The relation exists, with metadata equivalent to:

    {
      "name": "actor",
      "interface": "m2o",
      "type": "belongsTo",
      "collectionName": "tasks",
      "source": "tasks",
      "target": "users",
      "foreignKey": "actor_id",
      "targetKey": "id"
    }
  9. Inspect collections:listMeta. The actor field is absent from the runtime collection definition.

  10. Reload the browser or restart NocoBase. The field remains unavailable.

The metadata-level failure was also reproduced locally on NocoBase 2.2.19: a relation with source set to the collection name was persisted but absent from collections:listMeta. Changing only the problematic source value to null, while preserving the relation definition, made it appear in the runtime metadata.

Expected behavior

Relations created through the collection editor should load into the runtime collection definition and be available when configuring UI blocks.

The display-only “Source collection” value should not be persisted as the backend field-reference attribute source.

Screenshots

No screenshots attached. The discrepancy is observable by comparing the persisted and runtime metadata responses described above.

Logs

No relevant server log excerpt was captured. The metadata requests returned HTTP 200 rather than an API error.

The backend code path explains the missing runtime field:

const [sourceCollectionName, sourceFieldName] = options.source.split('.');
const sourceField = sourceCollection.fields.get(sourceFieldName);

For source: "tasks", sourceFieldName is undefined. When the source field cannot be found, Collection.setField logs a warning and returns null.

Relevant source files:

  • packages/plugins/@nocobase/plugin-data-source-manager/src/client-v2/pages/components/FieldForm.tsx — assigns the collection name to source during relation initialization and interface changes.
  • packages/core/database/src/collection.ts — interprets source as collection.field and skips fields whose source cannot be resolved.

The erroneous assignment was also confirmed in the JavaScript bundle installed in the affected production container.