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

Couldn't update subscription with default values #39

Closed
dnikolay-ebc opened this issue Sep 30, 2021 · 3 comments · Fixed by #42
Closed

Couldn't update subscription with default values #39

dnikolay-ebc opened this issue Sep 30, 2021 · 3 comments · Fixed by #42
Assignees
Labels
bug Something isn't working

Comments

@dnikolay-ebc
Copy link

Describe the bug
Method update_subscription of filip.clients.ngsi_v2.ContextBrokerClient has following configuration for request serialization:

res = self.patch(
                url=url,
                headers=headers,
                data=subscription.json(exclude={'id'},
                                       exclude_unset=True,
                                       exclude_defaults=True,
                                       exclude_none=True))

If a subscription is created/updated with non default values you can never re-set the default ones because defaults are excluded from serialization.

To Reproduce
Steps to reproduce the behavior:

As an example try to update the status of a subscription:

        with ContextBrokerClient(url='http://localhost:1026',
                                 fiware_header=FiwareHeader(
                                     service='fw-service',
                                     service_path='/testing',
                                 )) \
                as cb_client:

            subscription = cb_client.get_subscription('xyz')
            subscription.status = Status.INACTIVE

            cb_client.update_subscription(subscription)

→ subscription updates status to "inactive"

            subscription.status = Status.ACTIVE
            cb_client.update_subscription(subscription)

→ subscription still has status "inactive"

Environment (please complete the following information):

  • OS: Windows 10
  • Version 20H2
  • Python 3.8
@dnikolay-ebc dnikolay-ebc added the bug Something isn't working label Sep 30, 2021
@dnikolay-ebc
Copy link
Author

update_registration has same issue.

@tstorek
Copy link
Collaborator

tstorek commented Oct 5, 2021

@dnikolay-ebc which version of the library are you currently using?

@tstorek
Copy link
Collaborator

tstorek commented Oct 5, 2021

@dnikolay-ebc

I tested with a small example:

from pydantic import BaseModel, Field

class Model(BaseModel):
    test: str = Field(default='123')

model = Model(test='123')
print(model.json(exclude_defaults=True))

Does indeed skip the default although set, while

print(model.json(exclude_defaults=False))

would do the trick.
I am actually surprised by this behavior of pydantic.

We will correct this as soon as possible. However, this has to wait until #24 will be merged because this will probably come along with a breaking change

@dnikolay-ebc dnikolay-ebc self-assigned this Oct 6, 2021
@dnikolay-ebc dnikolay-ebc linked a pull request Oct 6, 2021 that will close this issue
tstorek added a commit that referenced this issue Oct 8, 2021
…ult-values

fix: include defaults in subscription update

closes #39
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
Resolve "refactor sphinx"

Closes RWTH-EBC#39

See merge request EBC/EBC_all/fiware/filip!37
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
dnikolay-ebc pushed a commit to dnikolay-ebc/FiLiP that referenced this issue Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants