Skip to content

Error: No table detected in the dashboard library when running sync #23

@jordangarrison

Description

@jordangarrison

Problem

I'm unable to update my library since January 3rd. I've tried updating the plugin as well. I'm on the current version of the plugin as of February 14, 2024 2:31 PM. I've also tried running the sync all updates on Mobile, Web and Desktop all of which give the same error.

Error: No table detected in the dashboard library

I, however, do have a table in my Library dashboard. I also saw a new update to limit the books to 500 by default. To ensure I wasn't hitting this limit I increased my setting to 5000 and the issue persisted.

Short investigation on the update

The only change I see is here: 7c9a443#diff-2db8cac33fb46ac0ad2c550c55935cc50e0769f6f82f1c6655188962f27d9118R764

There is only one clue I saw at the first pass which was this update to the function definition to use __ instead of _
7c9a443#diff-2db8cac33fb46ac0ad2c550c55935cc50e0769f6f82f1c6655188962f27d9118R764

The caller appears to still use _ here 7c9a443#diff-2db8cac33fb46ac0ad2c550c55935cc50e0769f6f82f1c6655188962f27d9118R792

Browser console error

I noticed when I looked at the browser console the following function was giving the error

  function _tableFromMarkdown(content) {
    console.debug(`_tableFromMarkdown(${content})`);
    let tableRegex = /^\s*\|(\s*\*\*[^|]+\*\*\s*\|)+$\n(\s*\|(.*\|)+$)+/gm;
    let tableMatch = content.match(tableRegex);
    if (!tableMatch) {
      console.error(`No table detected in the dashboard library`);
      throw new Error(`No table detected in the dashboard library`);
    }
    let lines = tableMatch[0].split("\n");
    if (lines.length < 2)
      return null;
    lines = lines.filter((row) => row.trim() !== "" && !row.trim().match(/^\s*\|([-\s]+\|\s*)+$/));
    if (!lines[0]) {
      console.error(`Dashboard has no meaningful rows: ${lines.join("\n")}`);
      throw new Error(`Dashboard has no meaningful rows: ${lines.join("\n")}`);
    }
    let headers;
    try {
      headers = lines[0].split("|").slice(1, -1).map((header) => header.trim().replace(new RegExp("\\*", "g"), ""));
    } catch (err) {
      if (err.name === "TypeError") {
        throw new Error(`${err.message} (line 887)`);
      }
    }
    const table = lines.slice(1).map((row) => {
      const cells = row.split(/(?<!\\)\|/).slice(1, -1).map((cell) => cell.trim());
      const rowObj = {};
      headers.forEach((header, i) => {
        if (cells[i] === "") {
          console.error(`Couldn't find a book property in the table.
Analyzing row: ${row}`);
          throw new Error(`Couldn't find a book property in the table.
Analyzing row: ${row}`);
        }
        if (cells[i] === void 0) {
          cells.push(`[No ${header}]`);
        }
        rowObj[header] = cells[i] || null;
      });
      if (rowObj.Cover) {
        rowObj.Cover = rowObj.Cover.replace(/!\[.+\|200]\(/mg, "![\\|200](");
      }
      return rowObj;
    });
    return table;
  }

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions