#2026 - http.agent.name is dropped from the robots.txt match set when http.robots.agents is set - #2027
Merged
Merged
Conversation
… http.robots.agents is set
…tp.robots.agents is set
rzo1
force-pushed
the
robots-agent-name-dropped
branch
from
July 27, 2026 11:30
187b952 to
a034ff4
Compare
jnioche
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2026.
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 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.Fix. Add
agentNames.add(agentName)before the append loop.agentNamesis aLinkedHashSet, so the existingindex++stays as-is and no duplicate is introduced.Two commits: the failing reproducer first, then the fix - happy to squash before merge.
For all changes
#XXXXwhereXXXXis the issue number you are trying to resolve?mvn git-code-format:format-code -Dgcf.globPattern="**/*" -Dskip.format.code=false? - not run yetFor code changes
mvn clean verify? - only theprotocolrobots tests were run locallyRobotRulesParserAgentNamesTest(4 tests, 3 of which fail without the fix)