New Rule Proposal: uid/gid should be integer #53
Comments
The user resource uid attribute can be a string or an integer. def uid(arg=nil)
set_or_return(
:uid,
arg,
:kind_of => [ String, Integer ]
)
end Two users, string vs integer uid: user "foo" do
uid "34567"
end
user "bar" do
uid 34568
end
Chef version 10.12.0. |
Hi Phil, Do you have any more detail on the situation where you saw this issue or can I close it? Joshua's example seems to show strings and integers are both valid. |
Just yesterday I had a block like:
try to resolve "12345" as a group name in 10.12. I'll try to get a reproduction posted today. |
This is indeed problematic for the group resource, which wasn't the original example: chef > recipe |
Indeed! def gid(arg=nil)
set_or_return(
:gid,
arg,
:kind_of => [ Integer ]
)
end |
In light of the inconsistency between the uid on user resource and gid on group resource, I think the preference should be to update Chef to allow strings for the gid. I created CHEF-3395 for this. A rule in foodcritic may be okay too, but I think this is the long term solution. |
So what's odd is that KC gets a crash, but I've had Chef tell me it can't resolve "xxxx" (some gid as a string) to a GID... which is different. |
Hmm. I cannot reproduce this in shef. Weird. I can reproduce KC's output. Your bug seems reasonable, @jtimberman. |
OK, here's the repro case:
The error is:
It doesn't happen every time though.... @jtimberman I told you I wasn't insane. :) |
Maybe you could add a warning for a string uid/gid that looks like an integer? Just ran into this as well... |
Awesome community-ness going on here. While I agree with @jtimberman - I think we should fix the upstream problem in Chef - Foodcritic is a linting tool aimed at provided consistency (among other things), so I'm in favor of having a rule to force consistency. |
It looks like @jtimberman fixed this in core chef back in 10.14.2 |
Specifying a user like:
Will cause chef to choke. FC should catch that this string is really an integer.
The text was updated successfully, but these errors were encountered: