Skip to content

ContextBrokerClient V2 post_entity method not compliant with the orion context broker implementation #421

@SystemsPurge

Description

@SystemsPurge

In the post_entity method of the V2 context broker client :

try:
    res = self.post(
        url=url,
        headers=headers,
        json=entity.model_dump(exclude_none=True),
        params=params,
    )
    if res.ok:
        self.logger.info("Entity successfully posted!")
        return res.headers.get("Location")
    res.raise_for_status()
except requests.RequestException as err:
    if err.response is not None:
        if update and err.response.status_code == 422:
            return self.override_entity(entity=entity, key_values=key_values)
        if patch and err.response.status_code == 422:
            if not key_values:
                return self.patch_entity(
                    entity=entity, override_attr_metadata=override_attr_metadata
                )
            else:
                return self._patch_entity_key_values(entity=entity)

According to this documentation, post entity is supposed to raise the 422 if upsert is not set, whereas 422 is being handled silently in the current implementation, by reconciling the entities in the context broker.
PS: The docs implementation is actually much simpler

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions