-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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] 3000.8 MySQL module does no longer return bytes #59754
Comments
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
I reopened this issue as the "fix" doesn't fix the bug, and makes things worst. Previously we're returning strings instead bytes, now we are returning wrong strings instead bytes. While the change in Already have a patch to fix it, but will do a bit more testing before send the PR. |
Probably you saw the problem that I mentioned in my last comment. While fixing it a question bugged me: all data returned by mysql module should be byte streams? Or you're only interested in the output of I am asking this because the need to encode/decode every string doesn´t seems reasonable for daily use. Let's say I need to compare the user privileges, instead @garethgreenaway as you did most of this module recent work, what do you think about this? |
We use a module that wraps some of the functionality of the mysql module. This module broke with the upgrade from 2019.2.8 to 3000.8. My initial goal was to get the old 2019.2.8 behavior restored, because I was unable to find anything related to it in the changelogs. Thinking about this again, this was also the time where the transition from Python 2 to Python 3 happened. As the comment states, the code wanted to avoid It would be nice to get some insight from the Salt devs on this. |
@sagetherage sorry to be annoying with this issue, but the merge that I did to return bytes in reality returns totally broken results. It's important to not release the mysql execution module as-is now. I have two different codes fixing the issue, but need a guide of which path to follow. Also, as @yiit87 points out, maybe the code actually doesn't need to return bytes after the Py2 to Py3 migration. I want to know what to do, probably some guidance from Core is needed. If we don't have enough time to discuss it, at least should be good to revert #60456 as the previous behaviour, returning strings, is better than the current one. |
Description
After upgrading from Salt 2019.2.8 to 3000.8 the
mysql
module returns strings instead of bytes.This issue is still present in master.
Steps to Reproduce the behavior
Just call
salt-call -l debug mysql.db_list
on 2019.2.8 and 3000.8 and observe the debug output.2019.2.8:
3000.8:
Expected behavior
The returned data should be bytes not str.
Versions Report
salt --versions-report for 2019.2.8
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)salt --versions-report for 3000.8
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Additional context
This issue is caused by the following code from https://github.com/saltstack/salt/blob/v3000.8/salt/modules/mysql.py#L424-L426 which was added with e871a3f in #56174:
While this removes all connection arguments that only contain an empty string, it also removes the
which, according to the comment in the file, was set deliberately set to
False
.Digging a little bit more, I found that the actual cause of this is a change in
config.option
, introduced with 16ea106 in #55637. Here, the default value of thedefault
parameter was changed from''
toNone
, only to change it further down either back to''
or to{}
depending on whether wildcard support is enabled or not.This leads to unexpected behavior and also breaks all calls to this function, that previously set
None
explicitly, like for example in the mysql module right here.now returns an empty string instead of
None
as instructed.--
I think the "proper" fix would be to change the config module as follows:
and remove the deepcopy for-loop in the mysql module:
With this change, config.option no longer silently swallows
None
and the mysql module is returning bytes again.The text was updated successfully, but these errors were encountered: