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

Working copy checkout broken for dataset with no CRS #855

Closed
enricofer opened this issue May 31, 2023 · 3 comments
Closed

Working copy checkout broken for dataset with no CRS #855

enricofer opened this issue May 31, 2023 · 3 comments

Comments

@enricofer
Copy link

Describe the bug
The provided kart repo appears to be clean. the kart fsck command doesn't report any issue but when trying to clone or recreate repo it throws a sqlalchemy exception.
How can I fix the faulty dataset?

To Reproduce
Steps to reproduce the behaviour:
0. download and unzip repo from: https://pashare.comune.padova.it/index.php/s/LAc8pNkgWFo2sJk

  1. kart --repo path_to/MASTER fsck is OK
  2. kart --repo path_to/MASTER clone path_to/MASTER_new throws exception
  3. kart --repo path_to/MASTER create-workingcopy --delete-existing throws exception

Expected behaviour
clone or create wc without issues

Output
....Writing features for dataset 15 of 26: a0102011_ConfiniComunali
kart helper: unhandled exception
Traceback (most recent call last):
File "sqlalchemy/engine/base.py", line 1900, in _execute_context
File "sqlalchemy/engine/default.py", line 736, in do_execute
pysqlite3.dbapi2.IntegrityError: FOREIGN KEY constraint failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "kart/helper.py", line 236, in helper
File "click/core.py", line 1130, in call
File "click/core.py", line 1055, in main
File "kart/cli_util.py", line 72, in invoke
File "click/core.py", line 1657, in invoke
File "click/core.py", line 1404, in invoke
File "click/core.py", line 760, in invoke
File "click/decorators.py", line 26, in new_func
File "kart/clone.py", line 181, in clone
File "kart/working_copy.py", line 250, in reset_to_head
File "kart/working_copy.py", line 292, in reset
File "kart/working_copy.py", line 184, in create_parts_if_missing
File "kart/tabular/working_copy/base.py", line 1348, in reset
File "kart/tabular/working_copy/base.py", line 1015, in write_full
File "kart/tabular/working_copy/gpkg.py", line 264, in _write_meta
File "sqlalchemy/orm/session.py", line 1714, in execute
File "sqlalchemy/engine/base.py", line 1705, in _execute_20
File "sqlalchemy/sql/elements.py", line 334, in _execute_on_connection
File "sqlalchemy/engine/base.py", line 1572, in _execute_clauseelement
File "sqlalchemy/engine/base.py", line 1943, in _execute_context
File "sqlalchemy/engine/base.py", line 2124, in handle_dbapi_exception
File "sqlalchemy/util/compat.py", line 211, in raise

File "sqlalchemy/engine/base.py", line 1900, in _execute_context
File "sqlalchemy/engine/default.py", line 736, in do_execute
sqlalchemy.exc.IntegrityError: (pysqlite3.dbapi2.IntegrityError) FOREIGN KEY constraint failed
[SQL: INSERT OR REPLACE INTO gpkg_geometry_columns (table_name, column_name, geometry_type_name, srs_id, z, m) VALUES (?, ?, ?, ?, ?, ?)]
[parameters: ('a0102011_ConfiniComunali', 'geom', 'MULTIPOLYGON', 0, 0, 0)]
(Background on this error at: https://sqlalche.me/e/14/gkpj)

**Version Info **

  • OS: Ubuntu 20.04 lts
  • Version:
    » GDAL v3.6.3; PROJ v9.2.0; PDAL v2.4.3
    » PyGit2 v1.9.0; Libgit2 v1.4.2; Git v2.38.1; Git LFS v3.3.0
    » SQLAlchemy v1.4.45; pysqlite3 v2.6.0/v3.40.1; SpatiaLite v5.0.1; Libpq v15.0.2
@olsen232
Copy link
Collaborator

The basic issue is that one of your datasets lacks a CRS.
A dataset not having a CRS should probably be allowed: I need to dig into this further and find out what is preventing this from working - clearly a FOREIGN KEY constraint has failed, but I need to figure out what should be happening instead.

In the meantime I have a workaround for you: the attached patch adds a CRS to the dataset, the same CRS as all your other datasets. Put the patch somewhere then run kart apply fix-crs.patch. Then run kart create-workingcopy to make sure your working copy is in a good state, since it might otherwise be missing some datasets that it didn't get around to writing when it crashed.

fix-crs.patch

@enricofer
Copy link
Author

The patch solved my issue. Thanks a lot.

@olsen232 olsen232 changed the title Can't fix faulty dataset Working copy checkout broken for dataset with no CRS Jun 8, 2023
@olsen232 olsen232 mentioned this issue Jun 11, 2023
3 tasks
@olsen232
Copy link
Collaborator

FOREIGN KEY constraint issue above fixed by #866

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants