Skip to content

Bug: get_aas_submodel_refs and get_concept_description_all pass invalid 'cursor' kwarg to response_t() #539

@zrgt

Description

@zrgt

Summary

Two handler methods in server/app/interfaces/repository.py call response_t(…, cursor=cursor), but APIResponse.__init__ accepts paging_metadata: Optional[PagingMetadata], not cursor. This causes a TypeError crash on every request to the affected endpoints, resulting in a 502 Bad Gateway from the WSGI server.

Affected endpoints

  • GET /shells/{aasIdentifier}/submodel-refsget_aas_submodel_refs (line ~592)
  • GET /concept-descriptionsget_concept_description_all (line ~951)

Traceback

File "server/app/interfaces/repository.py", line 592, in get_aas_submodel_refs
    return response_t(list(submodel_refs), cursor=cursor)
File "server/app/interfaces/base.py", in __init__
    super().__init__(*args, **kwargs, content_type=content_type)
TypeError: Response.__init__() got an unexpected keyword argument 'cursor'

Root cause

_get_slice() returns Tuple[Iterator[T], Optional[PagingMetadata]] (see base.py). The second element is already a PagingMetadata object (or None). The callers incorrectly name the argument cursor= instead of paging_metadata=.

Compare with the correct usage elsewhere in the same file, e.g. get_all_submodels:

paginated_submodels, paging_metadata = self._get_slice(request, submodels)
return response_t(list(paginated_submodels), paging_metadata=paging_metadata, ...)

Fix

# get_aas_submodel_refs (~line 592)
- return response_t(list(submodel_refs), cursor=cursor)
+ return response_t(list(submodel_refs), paging_metadata=cursor)

# get_concept_description_all (~line 951)
- return response_t(list(concept_descriptions), cursor=cursor, stripped=is_stripped_request(request))
+ return response_t(list(concept_descriptions), paging_metadata=cursor, stripped=is_stripped_request(request))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingserverSomething to do with the `server` package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions