Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug at startup of Zotero #11

Closed
WMAM opened this issue Jan 22, 2022 · 10 comments
Closed

bug at startup of Zotero #11

WMAM opened this issue Jan 22, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@WMAM
Copy link

WMAM commented Jan 22, 2022

Hi @daeh !
Just to report a minor bug. When launching Zotero, the following message appears:
imagen

After that, no other issue, the plugin continues to work fine

@daeh
Copy link
Owner

daeh commented Jan 22, 2022

Thanks for the heads up. It probably means that it's having trouble parsing some setting. Would you mind running this code snippet (Tools -> Developer -> Run Javascript) and posting the output?

async function runDebug () {
    const promptSaveErrors = false;
    debuglog = {};
    debuglog.version = Zotero.ObsCite.version;
    debuglog.zoteroVersion = Zotero.version;
    let prefs = {};
    for (let pref of ['matchstrategy', 'source_dir', 'zotkeyregex', 'metadatakeyword']) {
        try {
            prefs[pref] = Zotero.ObsCite.getPref(pref);
        } catch (e) {
            prefs[pref] = "Error (" + e.name + ") " + e.message;
        }
    }
    debuglog.prefs = prefs;

    let config = {};
    for (let pref of ['matchstrategy', 'source_dir', 'zotkeyregex', 'metadatakeyword', 'bbtinstalled']) {
        try {
            switch(pref) {
                case 'matchstrategy':
                    config[pref] = Zotero.ObsCite._getParam_matchstrategy();
                    break;
                case 'source_dir':
                    config[pref] = Zotero.ObsCite._getParam_vaultpath();
                    break;
                case 'zotkeyregex':
                    config[pref] = Zotero.ObsCite._getParam_zotkeyregex();
                    break;
                case 'metadatakeyword':
                    config[pref] = Zotero.ObsCite._getParam_metadatakeyword();
                    break;
                case 'bbtinstalled':
                    config[pref] = await Zotero.ObsCite._checkBBTinstalled();
                    break;
            }
        } catch (e) {
            config[pref] = "Error (" + e.name + ") " + e.message;
        }
    }
    try {
        config.checkSetting = await Zotero.ObsCite.checkSettings();
    } catch (e) {
        config.checkSetting = "Error (" + e.name + ") " + e.message;
    }
    debuglog.config = config;

    let results = {};
    try {
        await Zotero.ObsCite.processData(true);
        results.cleanrun = Zotero.ObsCite.cleanrun;
        results.ndataKeys = Zotero.ObsCite.dataKeys.length;
    } catch (e) {
        results = "Error (" + e.name + ") " + e.message;
    }
    debuglog.results = results;

    return debuglog;
}
return runDebug()

@daeh daeh added the bug Something isn't working label Jan 22, 2022
@WMAM
Copy link
Author

WMAM commented Jan 22, 2022

Sorry for being late...

{
"prefs": {
"matchstrategy": "bbtcitekey"
"source_dir": "C:\Obsidian\Zettelkasten"
"zotkeyregex": ""
"metadatakeyword": ""
}
"config": {
"matchstrategy": "bbtcitekey"
"zotkeyregex": ""
"metadatakeyword": ""
"checkSetting": true
}
"results": {
"cleanrun": true
"ndataKeys": 24
}
}

@daeh
Copy link
Owner

daeh commented Jan 23, 2022

I'm not sure what's going on, but it's possible that it's failing to find BBT at initialization. If you're up for helping me sort it out, here's a version with an extra debugging trace.

https://github.com/daeh/zotero-obsidian-citations/releases/download/v0.0.13alpha/zotero-obsidian-citations-0.0.13alpha.xpi

You can manually install it (Tools -> Add-ons -> Remove ZoteroObsidianCitations, Install Add-on From File -> zotero-obsidian-citations-0.0.13alpha.xpi, then restart Zotero. If you get the same error, run this code snippet and post the output (run it as 'not async', which should be the default):

Zotero.ObsCite.debuglog

Thanks!

@WMAM
Copy link
Author

WMAM commented Jan 23, 2022

Yes, the error persisted after changing to the v0.13alpha. Here is the output:

{
"version": "0.0.12"
"zoteroVersion": "5.0.97-beta.63+035aac30f"
"isMac": false
"isLinux": false
"isWin": true
"prefs": {
"matchstrategy": "bbtcitekey"
"source_dir": "C:\Obsidian\Zettelkasten"
"zotkeyregex": ""
"metadatakeyword": ""
}
"config": {
"matchstrategy": "bbtcitekey"
"source_dir": "C:\Obsidian\Zettelkasten"
"zotkeyregex": ""
"metadatakeyword": ""
"bbtinstalled": [
"0": true
]
"checkSetting": false
}
"trace": {
"checkSetting": "fail"
"processData": "unreached"
"ndataKeys": "unreached"
"updateItems": "unreached"
}
"failedSetting": {
"_getParam_matchstrategy": "none"
"_getParam_vaultpath": "none"
"_checkBBTinstalled": []
"_getParam_metadatakeyword": "none"
"_getParam_zotkeyregex": "none"
"matchstrategy": "none"
}
}

@daeh
Copy link
Owner

daeh commented Jan 23, 2022

yep, that's what's going on (ZOC fails to communicate with BBT at launch, then BBT becomes available later).

I thought that I had totally over-engineered the BBT initialization check, but it seems that it wasn't enough. I'll take a look at what I might be able to improve. Thanks for the feedback, it's very helpful.

@WMAM
Copy link
Author

WMAM commented Jan 23, 2022

Just in case it is useful...

The context options like "Open ObsidianMD note", do not appear until a manual sync is run.

@WMAM
Copy link
Author

WMAM commented Jan 23, 2022

... and BBT plugin was last updated on January 21. Maybe they changed something in their plugin

@daeh
Copy link
Owner

daeh commented Jan 23, 2022

see if this solves it:

https://github.com/daeh/zotero-obsidian-citations/releases/download/v0.0.13beta/zotero-obsidian-citations-0.0.13beta.xpi

(yeah, the Open in ObsidianMD item won't show up until the settings pass inspection, so if it doesn't pass at startup, then it won't show until the sync is manually invoked and the settings pass. That's all consistent with BBT not being found at initialization but being available later. Thanks.)

@WMAM
Copy link
Author

WMAM commented Jan 23, 2022

Yes... it did!

@daeh
Copy link
Owner

daeh commented Jan 23, 2022

great. thanks for reporting the issue

@daeh daeh closed this as completed Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants