theonedev/onedev · error · EntityNotFoundException

Unable to find agent:

Error message

Unable to find agent: 

What it means

AgentLogResource resolves the requested agent by the 'agent' parameter via AgentService.findByName; if no agent with that name is registered, it throws EntityNotFoundException("Unable to find agent: " + agentName). The server cannot locate any agent matching the supplied name.

Source

Thrown at server-core/src/main/java/io/onedev/server/web/resource/AgentLogResource.java:41

import io.onedev.server.service.AgentService;
import io.onedev.server.model.Agent;
import io.onedev.server.security.SecurityUtils;

public class AgentLogResource extends AbstractResource {

	private static final long serialVersionUID = 1L;

	private static final String PARAM_AGENT = "agent";
	
	@Override
	protected ResourceResponse newResourceResponse(Attributes attributes) {
		if (!SecurityUtils.isAdministrator()) 
			throw new UnauthorizedException();

		String agentName = attributes.getParameters().get(PARAM_AGENT).toString();
		Agent agent = OneDev.getInstance(AgentService.class).findByName(agentName);
		if (agent == null)
			throw new EntityNotFoundException("Unable to find agent: " + agentName);
		
		if (!agent.isOnline())
			throw new ExplicitException("Unable to read log: agent is offline");
		
		ResourceResponse response = new ResourceResponse();
		response.setContentType(MimeTypes.OCTET_STREAM);
		
		response.disableCaching();
		
		try {
			response.setFileName(URLEncoder.encode("agent-log.txt", StandardCharsets.UTF_8.name()));
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
		Long agentId = agent.getId();
		response.setWriteCallback(new WriteCallback() {

			@Override

View on GitHub (pinned to d44925c47c)

Solutions

  1. Check the exact agent name under Admin > Agents and correct the 'agent' parameter in the request/URL.
  2. Re-register the agent if it was deleted from the server.
  3. Update any scripts or bookmarks that reference the old agent name after a rename.

Example fix

// before
curl https://onedev/~agentlog?agent=build-agent-1  // deleted

// after: use current registered name
curl https://onedev/~agentlog?agent=build-agent-2
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the agent exists (and its exact name) before requesting logs
Agent agent = OneDev.getInstance(AgentService.class).findByName(agentName);
if (agent == null)
    throw new IllegalArgumentException("Unknown agent: " + agentName);

Prevention

When it happens

Trigger: GET on the agent log resource with an 'agent' parameter that does not match any registered agent name (typo, renamed agent, agent unregistered/deleted from the server).

Common situations: Agent was renamed or removed in Admin > Agents but old URLs/scripts still reference the old name; hard-coded agent names in automation scripts after re-provisioning; case/space mismatch between the parameter and registered name.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/b87c223755098a06. Report an issue: GitHub.