Skip to content

Fix empty string checks to use .isEmpty() instead of ==. - #1001

Open
fallingrock wants to merge 1 commit into
meilisearch:mainfrom
fallingrock:fix-equals
Open

fallingrock wants to merge 1 commit into
meilisearch:mainfrom
fallingrock:fix-equals

Conversation

@fallingrock

@fallingrock fallingrock commented Oct 21, 2026 •

Copy link
Copy Markdown

Pull Request

Related issue

Fixes #999

What does this PR do?

  • Fixes incorrect string comparison in Client.java

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • Bug Fixes
    • Improved tenant token generation when API key values are empty or null by correctly falling back to the client key.
    • Added consistent rejection of empty or invalid API key UIDs.
    • Retained validation for secret length, search rules, expiration settings, and UUID format before token creation.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 997b2e94-4b48-422e-a75d-370ca431c36d
📥 Commits

Reviewing files that changed from the base of the PR and between 76c96b3 and 61ca9e3.

📒 Files selected for processing: 1
  • src/main/java/com/meilisearch/sdk/Client.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Walkthrough

generateTenantToken now checks API keys, secrets, and API-key UIDs for empty content instead of comparing string references. Other validation remains unchanged.

Changes: Tenant token validation

Layer / File(s) Summary
Empty-string checks
src/main/java/com/meilisearch/sdk/Client.java
generateTenantToken uses isEmpty() to check the API key, secret, and API-key UID. Existing validation for secret length, search rules, expiry, and UUID remains in place.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: alallema

Merge Risk: ⚪ Minimal · up to 61ca9

The PR addresses the requested empty-string validation changes and is mergeable.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: replacing incorrect empty-string comparisons with .isEmpty().
Linked Issues check Passed Issue #999 requires content-based empty-string checks in Client.generateTenantToken. The diff replaces == "" with .isEmpty() for options.getApiKey(), removes the invalid secret == "" compari…
Out of Scope Changes check Passed The diff changes only empty-string validation in Client.generateTenantToken in Client.java. The changes support issue #999 and do not add unrelated behavior or files.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Full details: Linked Issues check

Explanation

Issue #999 requires content-based empty-string checks in Client.generateTenantToken. The diff replaces == "" with .isEmpty() for options.getApiKey(), removes the invalid secret == "" comparison, and replaces apiKeyUid == "" with a null-safe .isEmpty() check. These changes implement the requested coding behavior.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

Incorrect empty string comparisons in Client.java

1 participant