Skip to content

Conversation

@rishichintala
Copy link

@rishichintala rishichintala commented Sep 6, 2025

Summary
Fixes a bug in get_scm_info where the commits_by_line property is defined as boolean,
causing Boolean cannot be cast to String errors when invoking /api/sources/scm.

Changes

  • Changed property type from boolean to string.
  • Parse string into Boolean before API call.
  • Tested locally against SonarQube Community Edition with and without commits_by_line.

Verification

  • "commits_by_line" = "true" → works
  • "commits_by_line" = "false" → works
  • No param → works

Impact

  • Prevents runtime crash.
  • Aligns tool with SonarQube Web API contract.

Example:

  • "Get SCM info for file components/shared/Spinner.tsx in project code-frontend without per-line commits." The tool fails.

Observed Error

Error executing tool get_scm_info: Tool execution failed:
An error occurred during the tool execution:
class java.lang.Boolean cannot be cast to class java.lang.String
(java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')

Root Cause

  • In GetScmInfoTool.java, commits_by_line is defined as a boolean:

.addBooleanProperty(COMMITS_BY_LINE_PROPERTY, ...)

  • At runtime it is read with getOptionalBoolean().

  • This produces a Boolean, which is incompatible with the expected query string for the API.

@nquinquenel
Copy link
Member

nquinquenel commented Sep 8, 2025

Hey @rishichintala, thanks a lot for your contribution!

You’re absolutely right, we shouldn’t fail in this case. I’ve created a reference ticket here: MCP-106.

That said, the fix you proposed doesn’t fully cover the issue and is missing some tests. If you’re okay with it, I’ll handle the changes in a separate PR and also take the opportunity to improve the overall parsing of the tool’s parameters. Of course, I’ll make sure to credit your contribution.

Thanks again!

@nquinquenel nquinquenel self-assigned this Sep 8, 2025
@rishichintala
Copy link
Author

rishichintala commented Sep 8, 2025 via email

@nquinquenel
Copy link
Member

Fixed via #87

Thanks!

@nquinquenel nquinquenel closed this Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants