cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
353
Views
1
Helpful
2
Replies

NSO 6.2 Python API: Potential Bug in DataCallbacks register Method

ndmitri
Level 1
Level 1

Hello Cisco Community,

I've encountered what appears to be a bug in the DataCallbacks class implementation, specifically within the register method that is responsible for ensuring a data handler implements required methods. I would appreciate some guidance on whether this is indeed an issue, and if so, how it might be addressed.

Problem Description: The register method is designed to check that a handler object has implemented three methods: get_object, get_next, and count. However, the method only checks for the presence of get_object for all checks, ignoring get_next and count. Here's the problematic part of the code:

 

missing = []
for name in ('get_object', 'find_next', 'count'):
    if not _have_callable(handler, 'get_object'):
        missing.append(name)

 

Issues:

  1. Method Name Error: The tuple contains 'find_next', which seems to be a typo. It should likely be 'get_next'.
  2. Logical Error: The loop checks if get_object is callable for each iteration, rather than checking each method as intended. This could lead to incorrect validation of the handler's capabilities.

Expected Behavior: The method should correctly iterate through each required method name and check if the handler implements each one. The correct implementation might look like this:

 

missing = []
for name in ('get_object', 'get_next', 'count'):
    if not _have_callable(handler, name):
        missing.append(name)

 

Questions:

  • Has anyone else encountered this issue?
  • Is there an existing fix or workaround that I might have missed?
  • Could this be corrected in the documentation or the implementation?

Thank you for looking into this matter. I am eager to hear back from the community or the Cisco team regarding this potential issue.

2 Replies 2

jvikman
Cisco Employee
Cisco Employee

Hi ndimtri,

Nice find, I agree with you that it should be 'get_next' there.

There's no support for "experimental", otherwise I'd asked you to create a support ticket. But since there's no support I'll see if I can help you out with a fix.

BR,

Johan

Thank you.