Skip to content

Fix the bug : The /plugins page was displaying "Loading..." indefin…#939

Closed
jyjeanne wants to merge 1 commit intodita-ot:masterfrom
jyjeanne:master
Closed

Fix the bug : The /plugins page was displaying "Loading..." indefin…#939
jyjeanne wants to merge 1 commit intodita-ot:masterfrom
jyjeanne:master

Conversation

@jyjeanne
Copy link
Copy Markdown

Problem

@infotexture The plugins registry page at https://www.dita-ot.org/plugins was failing to load with a JavaScript error, leaving users with a perpetual "Loading..." message:

Failed to fetch plugins: TypeError: can't access property "localeCompare", e[0].name is undefined

Root Cause

The list() function in _js/plugins.js filters and sorts plugins from the registry API before rendering. The code assumed all plugin entries were valid arrays containing objects with a name property:

Object.values(json)
  .filter((plugin) => !!plugin && !plugin.alias)
  .sort((a, b) => a[0].name.localeCompare(b[0].name))  // ❌ Crashes here

However, the API response from https://plugins.dita-ot.org/_all.json contains some entries that are:

  • Empty arrays: []
  • Arrays with undefined or null elements
  • Arrays with objects missing the name property

When the sort function attempts to access a[0].name or b[0].name on these malformed entries, it throws a TypeError.

Solution

Enhanced the filter validation to check all required properties before attempting to sort:

Object.values(json)
  .filter((plugin) => !!plugin && !plugin.alias && plugin.length > 0 && plugin[0] && plugin[0].name)
  .sort((a, b) => a[0].name.localeCompare(b[0].name))  // ✅ Safe now

This ensures that only valid plugin entries proceed to the sort step by validating:

  1. !!plugin - Plugin exists (not null/undefined)
  2. !plugin.alias - Not an alias entry (existing check)
  3. plugin.length > 0 - Array has at least one element
  4. plugin[0] - First element exists
  5. plugin[0].name - Name property exists

Testing

✅ Tested locally with production plugin data from the registry API
✅ Verified plugin list displays correctly without errors
✅ Verified search and filter functionality works
✅ Confirmed no console errors in browser DevTools

Before

  • Plugins page shows "Loading..." indefinitely
  • Console displays TypeError
  • No plugins displayed

After

  • Plugins page loads successfully
  • Plugin list renders with all valid entries
  • Search and filter work correctly
  • No JavaScript errors

Files Changed

  • _js/plugins.js - Added enhanced validation to filter (1 line changed)

…itely with JavaScript error:...

Signed-off-by: jeremy <jyjeanne@gmail.com>
@jyjeanne
Copy link
Copy Markdown
Author

jyjeanne commented Feb 20, 2026

@infotexture @jelovirt i think there is also a problem into all.json file :
all.json

We also need a data fix.

Change the 3 array-wrapped alias entries to plain objects, consistent with the other 4 alias entries:

"org.doctales.ant-contrib": { "alias": "org.jung.ant-contrib" },
"org.doctales.schematron":  { "alias": "org.jung.schematron" },
"org.doctales.terminology": { "alias": "org.jung.terminology" }

Currently they are:

"org.doctales.ant-contrib": [{ "alias": "org.jung.ant-contrib" }],
"org.doctales.schematron":  [{ "alias": "org.jung.schematron" }],
"org.doctales.terminology": [{ "alias": "org.jung.terminology" }]

infotexture added a commit to dita-ot/registry that referenced this pull request Feb 20, 2026
Remove the outer array from the 3 JSON files that wrap a single alias object in an array, converting them to plain objects matching the pattern used by the other alias files.

Closes dita-ot/website#939

Signed-off-by: Roger Sheen <roger@infotexture.net>
@infotexture
Copy link
Copy Markdown
Member

@jyjeanne Thanks for your efforts here, but there was nothing wrong with the JavaScript code here in the website repo.

As you pointed out in your comment above, the root cause was a problem with the format of those recently merged alias entries in the plug-in registry.

Removing the outer array there in dita-ot/registry#171 was enough to resolve the issue.

@jyjeanne
Copy link
Copy Markdown
Author

@infotexture Thanks for your message . Upon my first analysis, I mistakenly focused on the JavaScript error in the Chrome browser console, but after a second, more thorough investigation of the all.json file, it became clear that the issue was into data.

jason-fox pushed a commit to jason-fox/registry that referenced this pull request Apr 12, 2026
Remove the outer array from the 3 JSON files that wrap a single alias object in an array, converting them to plain objects matching the pattern used by the other alias files.

Closes dita-ot/website#939

Signed-off-by: Roger Sheen <roger@infotexture.net>
Signed-off-by: Jason Fox <jason.fox@fiware.org>
jason-fox pushed a commit to jason-fox/registry that referenced this pull request Apr 13, 2026
Remove the outer array from the 3 JSON files that wrap a single alias object in an array, converting them to plain objects matching the pattern used by the other alias files.

Closes dita-ot/website#939

Signed-off-by: Roger Sheen <roger@infotexture.net>
Signed-off-by: Jason Fox <jason.fox@fiware.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants