sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
367 stars 149 forks source link

UnboundLocalError: local variable 'js' referenced before assignment #503

Closed giwdul86 closed 1 year ago

giwdul86 commented 1 year ago

I think sasiohttp.py contains a bug.

When connecting using authtoken, the _token is set in the constructor. When the _token exists, js is not assigned and line 359: self._token = js.get('access_token', None) raises the given error. Since the _token exists already, it does not need to be set. So for me using a try-except around lines 359/360 solves the issue.

tomweber-sas commented 1 year ago

Hey, I was on vacation the past week. sorry for not responding sooner. I will take a look at this in the morning and see what's up. Thanks for reporting this! Will provide more when I look into it in the morning. Thanks, Tom

tomweber-sas commented 1 year ago

Yep, I caused that regression with a rework of authentication code for changes in viya 4, and missed that case through the code. I'm fixing that today and hope to build a new release with the fix, before we're closed for the holidays next week. I'll post when I've got it ready!

Thanks, Tom

tomweber-sas commented 1 year ago

I've fixed this and pushed the code to main. Before creating a new release, could you possibly pull from main and test it out with your specific case? I want to be sure it works for your use case, like it works for me with the case I tried, before building the new release. If not, I can still go ahead; I saw the problem and verified the fix, but I like to be sure it solves yours too, in case there's something different. You can install main via: pip install git+https://git@github.com/sassoftware/saspy.git

Thanks, Tom

tomweber-sas commented 1 year ago

tell you what, I've gone ahead and published a new release, this is here, V4.2.2, and on PyPI, and Conda (w/in the next 24 hours as their bots build the new version). If it somehow doesn't fix your case I'll resolve that, but I'm pretty sure I have the problem fixed. Just pull the new release itself and give it a try:

pip uninstall -y saspy pip install saspy

SAS is closed until the new year, so I wanted to just build this for real and let you get it as production. Let me know either way, and we can address it. I'll try to check this next week when I can, and see if there's any issue, or it's fixed and working for you (that's what I expect).

Have a great holiday! Tom

tomweber-sas commented 1 year ago

V4.4.3 that is

tomweber-sas commented 1 year ago

Hey, I'm going to close this. I've verified the fix, simply passing in an authtoken to SASsession, which now works after fixing this bug. If you find there's anything still an issue with this, feel free to reopen. If you have anything else, just open another. And, thanks for opening this to begin with so I could fix this problem.

Thanks! Tom

giwdul86 commented 1 year ago

Couldn’t verfiy earlier, but 4.4.3 works for my case as well. Thanks for the quick fix!

tomweber-sas commented 1 year ago

Awesome! Thanks for verifying that for me! Tom