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

[google_chat_ros] check whether google_chat_button's parameters inclu… #501

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mqcmd196
Copy link
Member

When google_chat_ros receives NoneType parameters with python dictionaries generated from json, python's .get method returns None and it cannot be serialized with string format and raises

ROSSerializationException: field action.parameters[].key must be of type bytes or an ascii string

This PR fixes it

…de NoneType object for avoiding rospy serialization error
@k-okada
Copy link
Member

k-okada commented Dec 17, 2023

nice. can you describe how to reproduce this error ?
https://github.com/jsk-ros-pkg/jsk_3rdparty/tree/master/google_chat_ros#sending-an-interactive-button

@mqcmd196
Copy link
Member Author

Using the fetch1075's credential info and launch the node like

<include file="$(find google_chat_ros)/launch/google_chat.launch">
    <arg name="use_yaml" value="false" />
    <arg name="receiving_mode" value="pubsub" />
    <arg name="project_id" value="fetch-***" />
    <arg name="subscription_id" value="chat-sub" />
    <arg name="google_cloud_credentials_json" value="/home/obinata/Downloads/fetch-***.json" />
    <arg name="respawn" value="false" />
  </include>

then run the euslisp code

(setq *chat-space* "hoge") ;; set your own google chat space name with Fetch1075
(load "package://google_chat_ros/scripts/google-chat.l")
(setq buttons (list (create-google-chat-button "hello1" "hello1") (create-google-chat-button "hello2" "hello2")))
(send-google-chat-buttons *chat-space* buttons)

You may see the button on Google Chat.

On another terminal,

rostopic echo /google_chat_ros/card_activity

then press the button on Google Chat UI and you might encounter the error.

@mqcmd196
Copy link
Member Author

I wasn't sure whether to fix python code or euslisp library

(defun create-google-chat-button
    (button-name button-action-name
     &key (button-action-key) (button-action-value))
  (let ((button (instance google_chat_ros::Button :init))
        (text-button-on-click (instance google_chat_ros::OnClick :init))
        (action (instance google_chat_ros::FormAction :init))
        (parameter (instance google_chat_ros::ActionParameter :init)))
    (send button :text_button_name button-name)
    (send action :action_method_name button-action-name)
    (send parameter :key button-action-key)
    (send parameter :value button-action-value)
    (send action :parameters (list parameter))
    (send text-button-on-click :action action)
    (send button :text_button_on_click text-button-on-click)
    button))

it sets parameter 's key and value even if button-action-key and button-action-value were not given. So the button's parameter.key and parameter.value are empty.

But in any case, the element can be empty, so I modified the python node to handle it anyway.

@mqcmd196
Copy link
Member Author

mqcmd196 commented Oct 3, 2024

@k-okada Could you merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants