geofflambeth / seo-tools

CLI tools to quickly collect data and help audit webpages with tedious SEO tasks in mind.
GNU Affero General Public License v3.0
0 stars 0 forks source link

multiple rows when one or none expected #5

Open geofflambeth opened 15 hours ago

geofflambeth commented 15 hours ago

Seems there's some kind of an issue impacting the export. Only expected to have one row for each, but it appears there are multiple...

SELECT unique_url_page.id, unique_url_page.resolved_url, unique_url_page.declared_canonical_url, unique_url_page.evaluated_canonical_url, unique_url_page.page_title, unique_url_page.page_title_len, unique_url_page.meta_description, unique_url_page.meta_description_len, unique_url_page.meta_robots, unique_url_page.robots_header, unique_url_page.heading1, unique_url_page.heading2 
FROM unique_url_page 
WHERE unique_url_page.resolved_url = :resolved_url_1
Unexpected err=MultipleResultsFound('Multiple rows were found when one or none was required'), type(err)=<class 'sqlalchemy.exc.MultipleResultsFound'>
Traceback (most recent call last):
  File "/workspaces/quick-seo-audit-tools/.venv/bin/seo-tools", line 8, in <module>
    sys.exit(main_cli())
             ^^^^^^^^^^
  File "/workspaces/quick-seo-audit-tools/.venv/lib/python3.11/site-packages/seo_tools/__main__.py", line 48, in main_cli
    args.func(args)
  File "/workspaces/quick-seo-audit-tools/.venv/lib/python3.11/site-packages/seo_tools/subparsers/link_status/__init__.py", line 52, in parseArgsGetLinksStatus
    getLinksStatus(args.seed_url, args.output, args.contains)
  File "/workspaces/quick-seo-audit-tools/.venv/lib/python3.11/site-packages/seo_tools/subparsers/link_status/__init__.py", line 93, in getLinksStatus
    db.create_link_graph(network_visualization_path)
  File "/workspaces/quick-seo-audit-tools/.venv/lib/python3.11/site-packages/seo_tools/helpers/database.py", line 299, in create_link_graph
    edges = [(check_canonical_value(row.Link.source_url), check_canonical_value(row.Request.resolved_url)) for row in session.execute(stmt)]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/quick-seo-audit-tools/.venv/lib/python3.11/site-packages/seo_tools/helpers/database.py", line 299, in <listcomp>
    edges = [(check_canonical_value(row.Link.source_url), check_canonical_value(row.Request.resolved_url)) for row in session.execute(stmt)]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/quick-seo-audit-tools/.venv/lib/python3.11/site-packages/seo_tools/helpers/database.py", line 290, in check_canonical_value
    data = session.execute(stmt).scalar_one_or_none()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/quick-seo-audit-tools/.venv/lib/python3.11/site-packages/sqlalchemy/engine/result.py", line 1487, in scalar_one_or_none
    return self._only_one_row(
           ^^^^^^^^^^^^^^^^^^^
  File "/workspaces/quick-seo-audit-tools/.venv/lib/python3.11/site-packages/sqlalchemy/engine/result.py", line 805, in _only_one_row
    raise exc.MultipleResultsFound(
sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required
geofflambeth commented 15 hours ago

First noticed when using seed url https://geofflambeth.com, though the issue DOES NOT happen at https://geofflambeth.com/