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] INPUT_FUNCs 'monitor' and 'monitored' are broken (python errors when trying to use) #3312

Open
scyfris opened this issue Oct 29, 2023 · 3 comments
Labels
bug An actual error or unwanted behavior.

Comments

@scyfris
Copy link
Contributor

scyfris commented Oct 29, 2023

Describe the bug

Right now, monitor and monitored INPUT_FUNS seem to be broken.

There are two errors with the monitore-related functiosn in inputfuncs.py:

  1. monitor() has an error:
    outputfunc_name = kwargs("outputfunc_name", "monitor")

Needs to be

    outputfunc_name = kwargs.get("outputfunc_name", "monitor")
  1. monitored() asks for
    monitors = MONITOR_HANDLER.all(obj=obj)

This throws the error:

2023-10-29 14:55:35 [!!] Traceback (most recent call last):
2023-10-29 14:55:35 [!!]   File "C:\Users\Scyfris\Projects\evennia_new\evennia\evennia\server\sessionhandler.py", line 868, in call_inputfuncs
2023-10-29 14:55:35 [!!]     _INPUT_FUNCS[cname](session, *cmdargs, **cmdkwargs)
2023-10-29 14:55:35 [!!]   File "C:\Users\Scyfris\Projects\evennia_new\ev_norn\server\conf\inputfuncs.py", line 151, in monitored
2023-10-29 14:55:35 [!!]     session.msg(monitored=(monitors, [], {}))
2023-10-29 14:55:35 [!!]   File "C:\Users\Scyfris\Projects\evennia_new\evennia\evennia\server\serversession.py", line 298, in msg
2023-10-29 14:55:35 [!!]     self.data_out(**kwargs)
2023-10-29 14:55:35 [!!]   File "C:\Users\Scyfris\Projects\evennia_new\evennia\evennia\server\serversession.py", line 260, in data_out
2023-10-29 14:55:35 [!!]     self.sessionhandler.data_out(self, **kwargs)
2023-10-29 14:55:35 [!!]   File "C:\Users\Scyfris\Projects\evennia_new\evennia\evennia\server\sessionhandler.py", line 820, in data_out
2023-10-29 14:55:35 [!!]     self.server.amp_protocol.send_MsgServer2Portal(session, **kwargs)
2023-10-29 14:55:35 [!!]   File "C:\Users\Scyfris\Projects\evennia_new\evennia\evennia\server\amp_client.py", line 154, in send_MsgServer2Portal
2023-10-29 14:55:35 [!!]     return self.data_to_portal(amp.MsgServer2Portal, session.sessid, **kwargs)
2023-10-29 14:55:35 [!!]   File "C:\Users\Scyfris\Projects\evennia_new\evennia\evennia\server\amp_client.py", line 140, in data_to_portal
2023-10-29 14:55:35 [!!]     return self.callRemote(command, packed_data=amp.dumps((sessid, kwargs))).addErrback(
2023-10-29 14:55:35 [!!]   File "C:\Users\Scyfris\Projects\evennia_new\evennia\evennia\server\portal\amp.py", line 89, in dumps
2023-10-29 14:55:35 [!!]     return pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
2023-10-29 14:55:35 [!!] TypeError: 'NoneType' object is not callable

Looking into a bit more, it seems the the call

    monitors = MONITOR_HANDLER.all(obj=obj)

returns a list of things that can't all be pickleable , in particular the 'session' entry . An example of a call would be below:

[(scyfris, 'db_location', 1, False, {'name': 'location', 'session': scyfris(#1)@1:2:7:.:0:.:0:.:1, 'outputfunc_name': 'monitor'})]

Changing that to:

[(scyfris, 'db_location', 1, False, {'name': 'location', 'session': DEBUG', 'outputfunc_name': 'monitor'})]

Works fine.

Note sure the proper fix yet - just logging here for now.

To Reproduce

Use any client and test with the following:

    • Send a "monitor" message to the server. Any of them will hit the error with the missing ".get" on kwargs("outputfunc_name", "monitor")
  1. For the monitored issue, just send a "monitored" command after monitoring some value from the client. THIS REQUIRES A FIX TO THE ABOVE FIRST! You will see an error in logs/server.log indicated earlier in this bug.

Expected behavior

Things should work without python errors .

Environment, Evennia version, OS etc

Evennia 2.3.0 (rev 0b87f201fd)
OS: nt
Python: 3.10.6
Twisted: 22.10.0
Django: 4.1.11

NOTE: I am using a custom client , but I'm not doing anything custom about these INPUT_FUNCS.

@scyfris scyfris added bug An actual error or unwanted behavior. needs-triage Yet to be looked at and verified as an a real issue/feature that could be worked on labels Oct 29, 2023
@scyfris scyfris changed the title [BUG] INPUT_FUNCs 'monitor' and 'monitored' cause errors. [BUG] INPUT_FUNCs 'monitor' and 'monitored' are broken (python errors when trying to use) Oct 29, 2023
@scyfris
Copy link
Contributor Author

scyfris commented Oct 30, 2023

I'm taking a look at this now, so I don't mind picking it up sine I'm fixing it for my project anyways. (Inspector Caracal also mentioned writing unit tests for these - I will look to see what's needed there.)

@Griatch Griatch removed the needs-triage Yet to be looked at and verified as an a real issue/feature that could be worked on label Nov 26, 2023
@Griatch
Copy link
Member

Griatch commented Nov 26, 2023

@scyfris I fixed the trivial kwargs.get issue; the pickling of session is an interesting one - pickling happens for data sent over AMP between server and portal, and which is why this error happens on the .msg call. The reason the Session is not pickle-able is likely because it 'hides' database-tied objects 'inside' it. Easiest for this use case is likely to convert the Session to a string representation since its not used per-se on the portal side.

@scyfris
Copy link
Contributor Author

scyfris commented Dec 11, 2023

Thanks Griatch for fixing the get issue. I'll look at converting to string for the proper fix and submitting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An actual error or unwanted behavior.
Projects
None yet
Development

No branches or pull requests

2 participants