SonarSource/sonarqube · error · IllegalArgumentException
Missing parameter : 'comment'
Error message
Missing parameter : 'comment'
What it means
Thrown by the issue comment action when the 'comment' parameter is missing or empty. Adding a comment requires actual text; SonarQube validates this eagerly and raises IllegalArgumentException (HTTP 400).
Source
Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/CommentAction.java:62
comment(properties);
return true;
}
@Override
public boolean execute(Map<String, Object> properties, Context context) {
issueUpdater.addComment(context.issue(), comment(properties), context.issueChangeContext());
return true;
}
@Override
public boolean shouldRefreshMeasures() {
return false;
}
private static String comment(Map<String, Object> properties) {
String param = (String) properties.get(COMMENT_PROPERTY);
if (Strings.isNullOrEmpty(param)) {
throw new IllegalArgumentException("Missing parameter : '" + COMMENT_PROPERTY + "'");
}
return param;
}
}
View on GitHub (pinned to 184c821202)
Solutions
- Provide a non-empty 'comment' parameter in the request
- Validate the comment text is non-blank in the client before calling the API
- Fix shell/env variable expansion so the comment value is not empty
Example fix
// before curl -X POST '.../api/issues/add_comment?issue=AX1&comment=' // after curl -X POST '.../api/issues/add_comment?issue=AX1' --data-urlencode 'comment=Please fix before release'
Defensive patterns
Strategy: validation
Validate before calling
const comment = (message || '').trim();
if (!comment) throw new Error('comment text is required'); Try / catch
try { await post('/api/issues/add_comment', {issue, comment}); } catch (e) { if (e.status === 400 && e.message.includes("'comment'")) { /* supply non-empty text */ } else throw e; } Prevention
- Trim and check comment text before API calls
- Quote shell variables to prevent empty expansion
- Use --data-urlencode for form values
When it happens
Trigger: Calling POST api/issues/add_comment without the 'comment' parameter, or with comment='' ; also when a client serializes the field but sends an empty string.
Common situations: Script with an unquoted shell variable that expands to nothing; form/JSON body omitting the field; UI or bot posting comments where the message template rendered empty.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- One of the parameters 'severity' or 'impact' must be provide
- Issue with key '%s' does not exist
- Cannot sort on field :
- Component of type '%s' is not supported
- Parameters 'severity' and 'impact' cannot be used at the sam
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/93c620a63c762071.
Report an issue: GitHub.