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

[BUG] update_webhook doesn't work properly when you pass a webhook_obj #111

Open
MRyderOC opened this issue Feb 21, 2023 · 2 comments · Fixed by #113
Open

[BUG] update_webhook doesn't work properly when you pass a webhook_obj #111

MRyderOC opened this issue Feb 21, 2023 · 2 comments · Fixed by #113
Assignees
Labels
bug Something isn't working

Comments

@MRyderOC
Copy link
Collaborator

Expected Behavior

Update the webhook in the target agent.

Current Behavior

Does not perform any action.

Possible Solution

based on https://github.com/googleapis/python-dialogflow-cx/blob/f2d12c53804dec7b236509aa29b200aebcc53c8a/google/cloud/dialogflowcx_v3beta1/types/webhook.py#L305-L308

we have to update the mask only if the kwargs pass to the function and not when we pass the webhook_obj.

Steps to Reproduce

  1. Create a webhook in the agent.
  2. Pull the webhook using list_webhooks method in dfcx_scrapi.core.webhoks.Webhooks
  3. Change an attribute of the webhook e.g. timeout
from datetime import timedelta
my_webhook.timeout = timedelta(seconds=12)
  1. Update the webhook
webhook_instance.update_webhook(
    webhook_id=my_webhook.name,
    webhook_obj=my_webhook
)

Possible Implementation

mask = None
if kwargs:
    ... # existing code
    mask = field_mask_pb2.FieldMask(paths=paths)
... # existing code
if mask:
    request.update_mask = mask
... # existing code 
@MRyderOC MRyderOC added the bug Something isn't working label Feb 21, 2023
@MRyderOC MRyderOC self-assigned this Feb 24, 2023
MRyderOC added a commit that referenced this issue Feb 24, 2023
@MRyderOC MRyderOC mentioned this issue Feb 24, 2023
@MRyderOC MRyderOC linked a pull request Mar 3, 2023 that will close this issue
@kmaphoenix
Copy link
Member

@MRyderOC I just tested this on main and it seems to be working as intended.

If I don't pass any kwargs to the method, nothing is updated.
That is by design.

If I pass a kwarg to the method, it updates just fine.

from google.protobuf import duration_pb2 

all_webhooks = w.list_webhooks(pmarlow_demo)

duration = duration_pb2.Duration()
duration.seconds = 10

w.update_webhook(all_webhooks[0].name, all_webhooks[0], timeout=duration)

Before proto

name: "<WEBHOOK_ID>"
display_name: "long_running_webhook"
generic_web_service {
  uri: "<WEBHOOK_URI>"
}
timeout {
  seconds: 30
}

After proto

name: "<WEBHOOK_ID>"
display_name: "long_running_webhook"
generic_web_service {
  uri: "<WEBHOOK_URI>"
}
timeout {
  seconds: 10
}

@kmaphoenix
Copy link
Member

This specific bug will be addressed via another patch / branch.

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