theonedev/onedev · error · NotAcceptableException

Please login to perform this query

Error message

Please login to perform this query

What it means

PersonCriteria parses query values like '@me' or anonymous persons; when the query uses the current-user-dependent value but no one is authenticated, the criteria cannot resolve verified email addresses, so it throws a NotAcceptableException with a localized 'Please login to perform this query' message.

Source

Thrown at server-core/src/main/java/io/onedev/server/search/commit/PersonCriteria.java:55

	private boolean matches(String value, PersonIdent person) {
		String formatted = String.format("%s <%s>", person.getName(), person.getEmailAddress());
		return WildcardUtils.matchString(value, formatted);
	}

	private static UserService getUserService() {
		return OneDev.getInstance(UserService.class);
	}
	
	protected void fill(Project project, List<String> persons) {
		for (String value: values) {
			if (value == null) { // authored by me
				User user = SecurityUtils.getUser();
				if (user != null) {
					user.getVerifiedEmailAddresses().forEach(it-> {
						persons.add("<" + it + ">");
					});
				} else {
					throw new NotAcceptableException(_T("Please login to perform this query"));
				}
			} else if (value.startsWith("@")) {
				String userName = value.substring(1);
				User user = getUserService().findByName(userName);
				if (user != null) {
					for (String emailAddress: user.getVerifiedEmailAddresses()) {
						persons.add("<" + emailAddress + ">");
					}
				} else {
					persons.add(Strings.CS.replace(value, "*", ".*"));
				}
			} else {
				persons.add(Strings.CS.replace(value, "*", ".*"));
			}
		}
	}

	protected boolean matches(PersonIdent person) {

View on GitHub (pinned to d44925c47c)

Solutions

  1. Log in to OneDev in the current session before running the query
  2. Add an authentication token/credential to the REST/API call (Authorization header or basic auth)
  3. Rewrite the query to use an explicit '@username' or email value instead of the current-user value
  4. Wrap the call in try-catch for NotAcceptableException and redirect to login

Example fix

// before
restClient.queryCommits("server", "~me") // anonymous
// after
restClient.queryCommits("server", "@john") // or authenticate the request first
Defensive patterns

Strategy: try-catch

Validate before calling

// before running query
if (SecurityUtils.getUser() == null) { throw new IllegalStateException("login required for this query"); }

Try / catch

try { criteria.matches(ident); } catch (NotAcceptableException e) { redirectToLogin(); }

Prevention

When it happens

Trigger: Calling QueryContext/commit-query parsing or evaluation with a person value requiring SecurityUtils.getUser() (e.g. value starting with '~'/anonymous-to-me) while the request has no authenticated user session (anonymous access, REST call without auth token, or cron/API context without login).

Common situations: Hitting a saved query URL in an incognito browser; calling the commit query REST API without an authentication header; embedded query execution in a build/CI script where SecurityUtils.getUser() returns null.

Related errors


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