chrisgrieser/shimmering-obsidian

Bug: Error: TypeError: enabledCorePlugins.forEach is not a function

Closed this issue · 5 comments

Make sure you have done the following

  • I have updated to the latest version of this workflow.
  • I have read the documentation of the feature I am having problems with.
  • I am using Alfred 5. (Alfred 4 is not supported by this workflow anymore.)
  • I have updated to the latest version of the Metadata-Extractor and the Advanced URI plugin.
  • If the o… main search does not work, I made sure that I haven't changed any of the default settings of the Metadata-Extractor. Furthermore, I have tried rerunning osetup and it still does not work.
  • If notes in general can be found, but recently created or renamed notes cannot, I used the oupdate command to manually update the metadata.

Bug Description

Hi, thanks for this workflow, been using it daily. Just now when I go and run o, command, the search suddenly stopped and nothing return

image

After debugging with Alfred debugger, I have found the error enabledCorePlugins.forEach is not a function. Then I try to dig further into the issue, this is probably due to core-plugins.json is now a JSON object instead of array

image

Previously I can still use this o, command, so I think the most possible reason is a new Obsidian update I installed not long ago. My current Obsidian version is 1.7.4

This issue can be fixed on my side by keys() + filter() true value, but I not sure whether this is the same with original logic

Object.keys(enabledCorePlugins)
    .filter((key) => enabledCorePlugins[key])
    .forEach((/** @type {string} */ pluginID) => { ... });

Relevant Screenshot

No response

To Reproduce

  1. Type o, in Alfred
  2. "Search Obsidian Settings..." appear for around 1 second
  3. No further results shown

Debugging Log

[01:03:47.866] ERROR: Shimmering Obsidian[Script Filter] Code 1: /Users/andy/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A419B0AB-B26E-4D3C-9E37-20C17E24BD19/scripts/setting-search.js: execution error: Error: TypeError: enabledCorePlugins.forEach is not a function. (In 'enabledCorePlugins.forEach((/** @type {string} */ pluginID) => {
      const hasSettings = corePluginsWithSettings
        .map((/** @type {{ id: string; }} */ p) => p.id)
        .includes(pluginID);
      if (!hasSettings) return;

      const pluginName = corePluginsWithSettings.filter(
        (/** @type {{ id: string; }} */ item) => item.id === pluginID
      )[0].title;

      const URI = uriStart + "&settingid=" + pluginID;

      settings.push({
        title: pluginName,
        uid: pluginID,
        match: pluginName,
        arg: URI,
        icon: { path: "icons/plugin.png" },
        mods: {
          alt: { valid: false },
          cmd: { valid: false },
          fn: { valid: false },
          ctrl: {
            arg: pluginID,
            subtitle: "⌃: Copy plugin ID '" + pluginID + "'",
          },
        },
      });
    })', 'enabledCorePlugins.forEach' is undefined) (-2700)
[01:03:48.378] Shimmering Obsidian[Script Filter] Queuing argument '(null)'

Workflow Configuration

FYI my configurations are set as default except Vault Path if I'm not mistaken

image image image

Are you using Alfred in Compatibility Mode?

  • I am using Compatibility Mode.

Version & System Information

-------------------------------
INTERNAL WORKFLOW CONFIGURATION
Vault Path: /Users/andy/Library/Mobile Documents/iCloud~md~obsidian/Documents/Andy Vault
config folder: exists
Metadata JSONs: 3/4
Not all metadata found. Please run `osetup` and retry.
metadata.json String Length: 11521
-------------------------------
METADATA EXTRACTOR CONFIG
{"writingFrequency":"30","writeFilesOnLaunch":true}
-------------------------------
WORKSPACE DATA
'workspace.json' exists
-------------------------------
SYSTEM
macOS: 15.0.1
Alfred: 5.5.1
-------------------------------
INSTALLED VERSION
Obsidian: 1.7.4
This Workflow: 4.10.2
Advanced URI Plugin: 1.44.1
Metadata Extractor: 1.1.0
-------------------------------
LATEST VERSION
Obsidian: 1.7.4 (Insider: 1.7.4)
This Workflow: 4.10.2
Advanced URI Plugin: 1.44.1
Metadata Extractor: 1.1.0
-------------------------------

After debugging with Alfred debugger, I have found the error enabledCorePlugins.forEach is not a function. Then I try to dig further into the issue, this is probably due to core-plugins.json is now a JSON object instead of array

yep, that was the cause. Fixed it in the latest release:
Available in the Alfred Gallery in 1-2 days, or directly by downloading the latest release here: https://github.com/chrisgrieser/shimmering-obsidian/releases/download/4.10.3/shimmering-obsidian.alfredworkflow

As an open source maintainer that has too many projects to maintain: please feel free to make a PR if you already found the issue. Even if not perfect, a PR usually saves time on the maintainers end. :)
(and on your own end as well, since you do not have to fill out all of the bug report form.)

I was about to report this bug then I ended up here. Since I downloaded this workflow from Alfred Gallery I can right click and install the latest update this way. I wonder if any chances update delivery to end users automatically or get their attention about the update's availability. @chrisgrieser

The auto-updates from the gallery are rather subtle, yes. I am not really aware of a way for clearer notifications.

I'd suggest you open a feature request at the Alfred forum for this

In fact, some people did it before me. Found one topic that mentioned your workflow as well. Maybe you are right the auto-update from the gallery is the most stable way right now that built-in (I did not notice alfred has update available indicator after read this, not notification but this's fine) . With other workflows that are installed outside the gallery, the developer needs to implement the auto-update they own.

Yeah that post it outdated subs is from before the Gallery. The gallery updates themselves could be more noticeable