Skip to content

Admin UI: a Nullable relationship property (type ["relationship", "null"] or ["array", "null"]) is not handled as a relationship #270

Closed

Description

@vharseko

Describe the bug

The Admin UI finds the relationship properties of a managed object by comparing their type with the strings "relationship" and "array". The type array of a Nullable relationship, ["relationship", "null"] (#267), and of a Nullable relationship collection, ["array", "null"] with items of type "relationship" (#269), match neither. The schema editor of the Admin UI writes these type arrays itself: SchemaUtils.setNullableProperties turns the type of a Nullable property into [type, "null"].

On master (2a03690):

  • GenericEditResourceView.render builds the read of the edit view with ResourceCollectionUtils.getFieldsToExpand (:83), which adds a singleton relationship to _fields only for the type "relationship" (ResourceCollectionUtils.js:219). A relationship is not returned by default, so the value of a Nullable singleton relationship is not read, and the edit view shows it as not set. handleArrayOfTypes (:139) reduces the type arrays of the properties only after this read, before the editor is built.
  • ResourceCollectionUtils.convertRelationshipTypes (:174-184) replaces a relationship type with "string" and typeRelationship: true before the schema reaches JSONEditor, but passes a type array on unchanged. LinkedView (:108) calls it on the schema from getSchema without handleArrayOfTypes. JSONEditor 0.7.9 gives a type array to its multiple editor, which builds the editor of the first listed type right away (switchEditor(0) in build). There is no editor for "relationship", so getEditorClass throws Unknown editor for schema, and the linked view of a managed object with a Nullable singleton relationship is not rendered.
  • RelationshipWidget on the dashboard selects the relationship properties of a managed object, and of the managed objects it refers to (allSchemas), by the same comparisons (:466, :491), and leaves the Nullable ones out.
  • EditPropertyMappingDialog (:265) does not build the JSONEditor of the default value for a target property of type "relationship". For a Nullable relationship it builds one from {"type": ["relationship", "null"]} (:318), which throws as above when the dialog opens.

ResourceDelegate.getSchema gives these views the schema of a managed object, except EditPropertyMappingDialog, which gets it from AdminUtils.findPropertiesList. Both read managed.json through ConfigDelegate.readEntity, which returns a copy.

To reproduce

  1. In the Admin UI, open Configure > Managed Objects > User > Schema > manager, set Nullable and save.
  2. Open Manage > User and select a user whose manager is set. The Manager field offers to add a manager instead of showing the current one.
  3. In a mapping whose target is managed/user, open the dialog of a property mapping whose target is manager. The dialog fails, and the browser console shows Unknown editor for schema.

This was traced by reading the code on master and the source of JSONEditor 0.7.9, and has not been run in a browser.

Expected behavior

  • In the managed object schemas that ResourceDelegate.getSchema (with allSchemas) and AdminUtils.findPropertiesList return, a type array whose only type besides "null" is "relationship" reads "relationship", and ["array", "null"] with relationship items reads "array". The views and JSONEditor then handle a Nullable relationship like any other relationship.
  • The schema editor and managed.json keep the type arrays. The schema editor reads managed.json on its own and is not affected.

Corrected

The first version of this issue said that the edit view of a managed object with a Nullable singleton relationship is not rendered, and that a Nullable relationship collection gets no tab in it. Both are withdrawn: GenericEditResourceView.handleArrayOfTypes (:139) reduces the type arrays of the properties before the editor and the tabs are built. The Unknown editor for schema error applies to LinkedView and EditPropertyMappingDialog. In the edit view, only the read of the value is affected.

Activity

  1. added
    bug
    javascript
    ui
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugjavascriptui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions