adityamparikh opened a new pull request, #310:
URL: https://github.com/apache/solr-mcp/pull/310

   ## Summary
   
   This PR replaces string literals that `main` repeats across files with 
shared constants. Each constant lives in `util/`, the module every service 
already depends on, so no new cross-module dependencies appear. Behaviour is 
unchanged.
   
   | Literal | Uses | Now |
   |---|---|---|
   | `"isAuthenticated()"` | 32 `@PreAuthorize` | 
`SecurityExpressions.AUTHENTICATED` |
   | `"solr://collections"`, `"solr://{collection}/schema"`, 
`"solr://{collection}/fields"` | `@McpResource` in one service, `@McpComplete` 
in another | `ResourceUris.COLLECTIONS` / `COLLECTION_SCHEMA` / 
`COLLECTION_FIELDS` |
   | `"collection"`, `"Target Solr collection name"` | 4 prompt arguments, plus 
the completion handler's name check | `PromptNames.COLLECTION_ARG` / 
`COLLECTION_ARG_DESCRIPTION` |
   | `"application/json"` | 3 `@McpResource(mimeType = …)` | Spring's 
`MimeTypeUtils.APPLICATION_JSON_VALUE` |
   | `"*:*"` | `CollectionService` (private constant) and `SearchService` 
(literal) | `SolrQueries.MATCH_ALL`. SolrJ defines no such constant. |
   | `"Solr collection to index into"` | 4 in `IndexingService` | A private 
`COLLECTION_PARAM_DESCRIPTION` |
   
   ```diff
   -  @PreAuthorize("isAuthenticated()")
   -  @McpComplete(uri = "solr://{collection}/schema")
   +  @PreAuthorize(SecurityExpressions.AUTHENTICATED)
   +  @McpComplete(uri = ResourceUris.COLLECTION_SCHEMA)
      public List<String> completeCollection(CompleteRequest.CompleteArgument 
argument) {
   -    if (!"collection".equals(argument.name())) {
   +    if (!PromptNames.COLLECTION_ARG.equals(argument.name())) {
    ...
   -    } catch (SolrServerException | IOException _) {
   +    } catch (SolrServerException | IOException e) {
   +      // A completion is only a typing aid ... Logged at debug because 
clients ask on every keystroke.
   +      logger.debug("Collection completion could not list collections", e);
          return List.of();
   ```
   
   The completion handler used to drop its exception without logging it, so a 
Solr outage looked like "no matching collections". It now logs at debug, 
following *Effective Java* Item 77: don't ignore exceptions. It doesn't log at 
warn, because clients ask for completions on every keystroke.
   
   ## Evidence
   
   - After the change, `grep` finds these literals in `src/main` only where the 
constants are defined, plus two Javadoc mentions of `*:*`.
   - `./gradlew build`: 518 tests, 0 failures, 0 skipped.
   
   ## Merge Danger
   
   **Door:** two-way
   
   **Blast Radius:** none
   
   The constants hold the same values as the literals they replace, so the 
annotations compile to the same bytecode. #294, #307 and #308 touch some of the 
same annotations, so whichever merges second needs a small rebase.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to