Found the bug:

irb(main):002:0> ldap.search2(ASF::Group.base,
::LDAP::LDAP_SCOPE_ONELEVEL, 'cn=db-site', 'memberUID')
=> [{"dn"=>["cn=db-site,ou=groups,dc=apache,dc=org"]}]

irb(main):003:0> ldap.search2(ASF::Group.base,
::LDAP::LDAP_SCOPE_ONELEVEL, 'cn=axis', 'memberUID')
=> [{"memberUid"=>["saminda", "tomj", "deepal", "gdaniels",
"davidillsley", "chinthaka", "sandakith", "ruchithf", "supun",
"muthulee", "hemapani", "upul", "dinesh", "ruwan", "thilina",
"sumedha", "damitha", "shankar", "samisa", "nandika", "dimuthu",
"prabath", "pzf", "nandana", "milinda", "azeez", "senaka", "sanjiva",
"nagy", "ajith", "isurues", "gawor", "keithc", "scheu", "barrettj",
"veithen", "amilas", "nthaker", "saram", "robertlazarski", "rott",
"gatfora", "sagara", "parsonsd", "dumindu", "dsosnoski", "nadiramra",
"dobri", "danushka", "herven", "pini", "lahiru", "lorivg",
"thilinamb", "eranga", "aslom", "amilaj", "shameera", "amantaut",
"kishanthan", "hiranya"],
"dn"=>["cn=axis,ou=groups,dc=apache,dc=org"]}]

Note that there isn't an empty list for memberUID in the first
results, there literally is nothing there.

Fixed by:

https://github.com/apache/whimsy/commit/b933b4577a9ffb043c76d4716c6aa3434ae232da

- Sam Ruby


On Tue, Jan 26, 2016 at 8:46 PM, Sam Ruby <[email protected]> wrote:
> On Tue, Jan 26, 2016 at 8:16 PM, sebb <[email protected]> wrote:
>> The json file https://whimsy.apache.org/public/public_ldap_groups.json
>> is causing a problem, because one of the roster entries is a null:
>>
>>  "db-site": {
>>       "modifyTimestamp": "20100210202350Z",
>>       "roster": [
>>         null
>>       ]
>>     },
>>
>> It should be empty.
>>
>> The loop that creates the entry is:
>>
>> groups.keys.sort_by {|a| a.name}.each do |entry|
>>     m = []
>>     entry.members.sort_by {|a| a.name}.each do |e|
>>         m << e.name
>>     end
>>     lastStamp = entry.modifyTimestamp if entry.modifyTimestamp > lastStamp
>>     entries[entry.name] = {
>>         modifyTimestamp: entry.modifyTimestamp,
>>         roster: m
>>     }
>> end
>>
>> To try and debug the code, I tried only processing some of the keys.
>> Of course then the code worked.
>> Eventually I found that the 'committers' entry is the culprit.
>> If one skips the loop body for that entry, then db-site is output correctly.
>>
>> Any idea why the db-site members field appears to be being corrupted?
>> It looks like something is generating a Person entry with a null name
>> and storing it in the db-site members field.
>> Perhaps an issue with the LazyHash?
>
> I don't know about committers, but I'm seeing a problem with db-site,
> all by itself without any program wrapped around it:
>
> $ ruby -r whimsy/asf -e "p ASF::Group.find('db-site').members"
> [#<ASF::Person:0x00000002722ea8 @name=nil>]
>
> $ ruby -r whimsy/asf -e "p ASF.search_one(ASF::Group.base,
> 'cn=db-site', 'memberUID')"
> [nil]
>
> Possible fixes:
>
> (1) in public_ldap_groups.rb:
>
>   m << e.name if e.name
>
> (2) in asf/ldap.rb, method ASF::Group.list:
>
>   ASF.search_one(base, filter, 'cn').flatten.compact.map {|cn| find(cn)}
>
> - Sam Ruby

Reply via email to