l1xnan / obsidian-better-export-pdf

Obsidian PDF export enhancement plugin
MIT License
240 stars 13 forks source link

TypeError: Cannot read properties of undefined (reading 'indexOf') #210

Open AMGMNPLK opened 1 month ago

AMGMNPLK commented 1 month ago

Description

When exporting a "UNTITLE CHAT" note by Smart Connection: A TypeError is occurring in the ScSmartView2.add_link_listeners function of the smart-connections plugin. The error message indicates that the code is trying to read the indexOf property of an undefined value.

Expected Behavior

Print the visible note without encountering any errors.

Actual Behavior

The plugin throws a TypeError when attempting to read the indexOf property of an undefined value in the ScSmartView2.add_link_listeners function.

Error Stack Trace

TypeError: Cannot read properties of undefined (reading 'indexOf')
    at ScSmartView2.add_link_listeners (plugin:smart-connections:9344:23)
    at eval (plugin:smart-connections:10153:80)
    at NodeList.forEach (<anonymous>)
    at SmartConnectionsPlugin.render_code_block_context (plugin:smart-connections:10153:50)
    at app.js:1:1222590
    at t.postProcess (app.js:1:1295625)
    at t.<anonymous> (app.js:1:2305507)
    at app.js:1:237056
    at Object.next (app.js:1:237161)
    at a (app.js:1:235879)

Feel free to provide any additional details or clarifications that could assist in resolving the issue.

l1xnan commented 1 month ago

Guess this exception wasn't handled properly: https://github.com/brianpetro/obsidian-smart-connections/blob/367f17767e84fe86fb2208ec1f1154d70af7687c/src/sc_smart_view.js#L200

- if (item.path.indexOf("{") > -1) return;
+ if (!item?.path || item.path.indexOf("{") > -1) return;