RobotRulesParser.setConf() never adds http.agent.name to agentNames when http.robots.agents is non-empty:
- if the advertised name is listed first,
index++ skips it and the loop appends only agents[1..], so the name is dropped entirely;
- if it is not listed first, the code logs "Agent we advertise (X) not listed first" and appends the configured list, still without adding the name.
agentNames is only ever written in the empty-list branch and in that loop, which contradicts the in-code comment: "If both are present, our agent-string should be the first one we advertise to robots-parsing."
Impact
With http.agent.name: mybot and http.robots.agents: mybot,mybot-uk, the match set handed to crawler-commons is [mybot-uk]. A User-agent: mybot group in a robots.txt does not match and the parser falls back to *. Rules addressed specifically to the crawler are ignored, which is a compliance issue rather than a cosmetic one.
Reproducer
With a robots.txt of:
User-agent: mybot
Disallow: /restricted/
User-agent: *
Disallow: /
and http.agent.name: mybot, http.robots.agents: mybot,mybot-uk, /index.html is reported as disallowed because the wildcard group is selected.
Nothing in core/src/test currently references http.robots.agents.
Fix
Add agentNames.add(agentName) before the append loop. agentNames is a LinkedHashSet, so the existing index++ can stay and no duplicate is introduced.
RobotRulesParser.setConf()never addshttp.agent.nametoagentNameswhenhttp.robots.agentsis non-empty:index++skips it and the loop appends onlyagents[1..], so the name is dropped entirely;agentNamesis only ever written in the empty-list branch and in that loop, which contradicts the in-code comment: "If both are present, our agent-string should be the first one we advertise to robots-parsing."Impact
With
http.agent.name: mybotandhttp.robots.agents: mybot,mybot-uk, the match set handed to crawler-commons is[mybot-uk]. AUser-agent: mybotgroup in a robots.txt does not match and the parser falls back to*. Rules addressed specifically to the crawler are ignored, which is a compliance issue rather than a cosmetic one.Reproducer
With a robots.txt of:
and
http.agent.name: mybot,http.robots.agents: mybot,mybot-uk,/index.htmlis reported as disallowed because the wildcard group is selected.Nothing in
core/src/testcurrently referenceshttp.robots.agents.Fix
Add
agentNames.add(agentName)before the append loop.agentNamesis aLinkedHashSet, so the existingindex++can stay and no duplicate is introduced.