Skip to content

schema-pane render() ignores subject parameter, hardcodes #this — breaks for any data with non-#this @id #11

@melvincarvalho

Description

@melvincarvalho

Symptom

Page goes blank with two console errors when loading a LOSOS doc whose top-level `@id` is anything other than `#this`:

```
[schema-pane] Failed to load schema: TypeError: Cannot read properties of null (reading 'name')
at schema-pane.js:293:29
at Array.map ()
at renderForm (schema-pane.js:285:37)
at schema-pane.js:73:69
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'name')
```

The unhandled rejection halts the shell mid-render — no panes appear with content, even ones that wouldn't have failed.

Reproduction

Any inline JSON-LD data island whose root has an explicit absolute `@id`:

```html

<script type=\"application/ld+json\"> { \"@id\": \"https://example.org/profile/card#me\", \"@type\": \"Person\", \"name\": \"Alice\" } </script>

```

Real-world example that hit this: https://solid-apps.github.io/profile/ (since fixed by changing `@id` to `#this` — but that papers over the bug).

Root cause

`losos/panes/schema-pane.js`:

```js
canHandle(subject, store) {
var node = store.get(subject.value) // line 14: uses subject.value ✓
...
}

render(subject, lionStore, container, rawData) {
...
var root = store.get('#this') // line 35: hardcoded '#this' ✗
...
```

The `render()` method ignores the `subject` parameter and hardcodes `store.get('#this')`. When the doc's @id is e.g. a real WebID, `#this` doesn't exist as a node, `root` is `null`, and downstream `root[key]` (line 293) throws `Cannot read properties of null (reading 'name')` for whichever schema property is iterated first that happens to match a key on `root`.

`shell.js`'s `findSubject()` correctly resolves the subject (`?uri=` fragment, then `#this`, then first node with `@type`) and passes it to `render(subject, ...)`. `schema-pane.canHandle()` honors it. `render()` doesn't.

Suggested fix

```diff

  • var root = store.get('#this')
  • var root = store.get(subject.value)
    ```

That's the whole patch. `canHandle` and `render` would then agree on which node is the active subject.

Why it took us a minute to find

The error message points at line 293 (`root[key]`), not line 35 where the bad `store.get('#this')` happens. The first instinct is to look at the schema ("why is a property null?") rather than at `root` itself being null. Worth a comment near line 35 noting that `subject.value` is intentionally ignored if the change isn't desired — saves the next person an evening.

Related

  • The same hardcode pattern may exist elsewhere — worth a grep across `panes/` for `store.get('#this')` to confirm.
  • Encountered while building https://solid-apps.github.io/profile/ which now uses `@id: #this` to work around. Would prefer to use real WebIDs in inline data once this lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions