atviriduomenys / spinta

Spinta is a framework to describe, extract and publish data (a DEP Framework).
MIT License
10 stars 4 forks source link

Date: Invalid value error #516

Closed sirex closed 9 months ago

sirex commented 9 months ago

When running following query:

URL=https://get-test.data.gov.lt/datasets/gov/rc/jar/iregistruoti/JuridinisAsmuo
http "$URL/?select(reg_data,ja_pavadinimas)&format(csv)&limit(1)&sort(reg_data)"

I get following error:

HTTP/1.1 200 OK
Transfer-Encoding: chunked
content-disposition: attachment; filename="JuridinisAsmuo.csv"

http: LogLevel.ERROR: ChunkedEncodingError:
InvalidChunkLength: got length b'', 0 bytes read

get-test.data.gov.lt logs show:

Traceback (most recent call last):
  File "spinta/utils/response.py", line 246, in aiter
    for data in stream:
  File "spinta/formats/csv/commands.py", line 59, in _render_csv
    for row in rows:
  File "spinta/utils/nestedstruct.py", line 15, in flatten
    for v in vals:
  File "spinta/accesslog/__init__.py", line 162, in log_response
    for row in rows:
  File "spinta/commands/read.py", line 126, in <genexpr>
    rows = (
  File "spinta/commands/read.py", line 216, in get_page
    for row in rows:
  File "spinta/backends/postgresql/commands/read.py", line 52, in getall
    expr = env.resolve(query)
  File "spinta/backends/postgresql/commands/query.py", line 463, in and_
    args, kwargs = expr.resolve(env)
  File "spinta/ufuncs/basequerybuilder/ufuncs.py", line 24, in paginate
    return env.resolve(_get_pagination_compare_query(page))
  File "spinta/backends/postgresql/commands/query.py", line 473, in or_
    args, kwargs = expr.resolve(env)
  File "spinta/backends/postgresql/commands/query.py", line 473, in or_
    args, kwargs = expr.resolve(env)
  File "spinta/backends/postgresql/commands/query.py", line 524, in compare
    return env.call(op, prop.dtype, value)
  File "spinta/backends/postgresql/commands/query.py", line 593, in compare
    raise exceptions.InvalidValue(dtype, op=op, arg=type(value).__name__)
spinta.exceptions.InvalidValue: Invalid value.
  Context:
    component: spinta.types.datatype.Date
    manifest: default
    schema: 2536
    dataset: datasets/gov/rc/jar/iregistruoti
    model: datasets/gov/rc/jar/iregistruoti/JuridinisAsmuo
    entity:
    property: reg_data
    attribute:
    type: date
    op: gt
    arg: date
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "uvicorn/protocols/http/httptools_impl.py", line 404, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "spinta/middlewares.py", line 29, in __call__
    await self.app(scope, receive, send)
  File "starlette/middleware/exceptions.py", line 83, in __call__
    raise RuntimeError(msg) from exc
RuntimeError: Caught handled exception, but response already started.

Might be related with: