Skip to content

Fix Kartverket API error on cloud #18

@jathavaan

Description

@jathavaan

Task description

The logs can be viewed below

2025-10-27 08:54:46,452 - INFO - County '11' has 305603 features after clipping.
2025-10-27 08:54:47,878 - INFO - Uploaded blob 'osm/release/2025-10-27.5/theme=buildings/region=11/part_00000.parquet'. It can be accessed at: https://doppablobstorage.blob.core.windows.net/raw/osm/release/2025-10-27.5/theme%3Dbuildings/region%3D11/part_00000.parquet
2025-10-27 08:54:48,234 - INFO - Uploaded blob 'osm/release/2025-10-27.5/theme=buildings/region=11/part_00001.parquet'. It can be accessed at: https://doppablobstorage.blob.core.windows.net/raw/osm/release/2025-10-27.5/theme%3Dbuildings/region%3D11/part_00001.parquet
2025-10-27 08:54:48,234 - INFO - Processing county '39'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 198, in _new_conn
    sock = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 488, in _make_request
    raise new_e
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 464, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1093, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 753, in connect
    self.sock = sock = self._new_conn()
                       ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 207, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f3619bb1950>, 'Connection to api.test.kartverket.no timed out. (connect timeout=None)')

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 644, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 841, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 519, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.test.kartverket.no', port=443): Max retries exceeded with url: /kommuneinfo/v1//fylker/39/omrade?utkoordsys=4326 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f3619bb1950>, 'Connection to api.test.kartverket.no timed out. (connect timeout=None)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/main.py", line 14, in <module>
    main()
  File "/app/main.py", line 10, in main
    extract_osm_buildings()
  File "/usr/local/lib/python3.11/site-packages/dependency_injector/wiring.py", line 1194, in _patched
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/app/src/presentation/entrypoints/open_street_map_pipeline.py", line 15, in extract_osm_buildings
    osm_service.create_osm_parquet_file(release=release)
  File "/app/src/infra/infrastructure/services/open_street_map_service.py", line 57, in create_osm_parquet_file
    county_wkb = self.__county_service.get_county_wkb_by_id(county_id=county_id, epsg_code=EPSGCode.WGS84)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/infra/infrastructure/services/county_service.py", line 24, in get_county_wkb_by_id
    response = requests.get(
               ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 665, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.test.kartverket.no', port=443): Max retries exceeded with url: /kommuneinfo/v1//fylker/39/omrade?utkoordsys=4326 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f3619bb1950>, 'Connection to api.test.kartverket.no timed out. (connect timeout=None)'))

Exception in thread Thread-1 (_stream_container_events_and_logs):
Traceback (most recent call last):
  File "threading.py", line 1043, in _bootstrap_inner
  File "threading.py", line 994, in run
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/container/custom.py", line 1184, in _stream_container_events_and_logs
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/container/custom.py", line 1138, in _stream_logs
AttributeError: 'NoneType' object has no attribute 'split'

Several API calls are successful before this and the specifc county also works fine using the command curl -v https://api.test.kartverket.no/kommuneinfo/v1/fylker/39/omrade?utkoordsys=4326

This may be an error that is caused by Kartverkets API

Developer tasks

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions