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]: Strings over RPC fail to be parsed #13

Closed
N3X15 opened this issue May 28, 2024 · 3 comments
Closed

[Bug]: Strings over RPC fail to be parsed #13

N3X15 opened this issue May 28, 2024 · 3 comments

Comments

@N3X15
Copy link

N3X15 commented May 28, 2024

Steps to reproduce

// Note: This file doesn't actually need to exist.
namespace Your.RPC
{
    public static class Class
        /// <summary>
        /// Test method
        /// </summary>
        /// <param name="aString"></param>
        [Preserve]
        public static void AMethodThatAcceptsASingleString(string aString)
        {
            // Will never make it here.
            AssertIsDevBuild();
            Debug.Log("SUCCESS");
        }
    }
}
from gamium import *

service = TcpGamiumService("127.0.0.1", 50061)
gamium = GamiumClient(service)

gamium.connect()

# Send any non-numeric string over RPC
gamium.execute_rpc(
    RpcBy.method(
        "Your.RPC.Class",
        "AMethodThatAcceptsASingleString",
        "c11557d5-ffcc-47fc-9263-2b1717eb070d",
    )
)

Expected result

Client successfully sends the request and prints out SUCCESS in console.

Actual result

Client crashes prior to sending request to server.

$ python test.py
INFO: GamiumClient.connect
INFO: Connecting to 127.0.0.1:50061
INFO: GamiumClient.execute_rpc By: 0, class: Your.RPC.Class, target: AMethodThatAcceptsASingleString
Traceback (most recent call last):
  File "F:\ABI\cvr_unit_tests\test.py", line 7, in <module>
    gamium.execute_rpc(
  File "C:\Users\N3X15\AppData\Local\pypoetry\Cache\virtualenvs\cvr-unit-tests-K3olf5zB-py3.11\Lib\site-packages\gamium\gamium_client.py", line 135, in execute_rpc
    res = self._service.request(create_execute_rpc(locator.by, locator.class_name, locator.target_name, params))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\N3X15\AppData\Local\pypoetry\Cache\virtualenvs\cvr-unit-tests-K3olf5zB-py3.11\Lib\site-packages\gamium\tcp_gamium_service.py", line 104, in request
    raise e
  File "C:\Users\N3X15\AppData\Local\pypoetry\Cache\virtualenvs\cvr-unit-tests-K3olf5zB-py3.11\Lib\site-packages\gamium\tcp_gamium_service.py", line 98, in request
    return self.pop_message(req)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\N3X15\AppData\Local\pypoetry\Cache\virtualenvs\cvr-unit-tests-K3olf5zB-py3.11\Lib\site-packages\gamium\tcp_gamium_service.py", line 126, in pop_message
    raise GamiumError(response.error.code, f"request response error: {reason}")
gamium.errors.gamium_error.GamiumError: (301, "request response error: Unexpected character encountered while parsing value: c. Path '', line 0, position 0.")

Version

2.0.9

@N3X15
Copy link
Author

N3X15 commented May 28, 2024

Use-case: Our testing process requires that we send GUIDs over RPC for loading worlds, since actually browsing for the world in UI is currently an overly-complicated task for automation.

WORKAROUND: Sending a Dict[str, Any] seems to work fine:

# Send any GUID over RPC
gamium.execute_rpc(
    RpcBy.method(
        "Your.RPC.Class",
        "AMethodThatAcceptsAJSONObject",
        {"guid": "c11557d5-ffcc-47fc-9263-2b1717eb070d"},
    )
)

You will, however, need to change your method signature:

        /// <summary>
        /// Test method
        /// </summary>
        [Preserve]
        public static void AMethodThatAcceptsAJSONObject(JObject json)
        {
            var guid = (string)json["guid"];
            Debug.Log("AMethodThatAcceptsAJSONObject: "+guid);
        }

yowpark added a commit to dogu-team/gamium-unity-samples that referenced this issue Jun 4, 2024
@yowpark
Copy link
Contributor

yowpark commented Jun 4, 2024

The problematic code has been fixed, but deploy will be delayed due to PyPI account issues.

@yowpark
Copy link
Contributor

yowpark commented Jun 5, 2024

Fixed in version 2.0.10.

@yowpark yowpark closed this as completed Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants