Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,24 @@ authorization_header_1:
.get_keys()
.await
.unwrap();
tenant_token_guide_generate_sdk_1: |-
let api_key = "B5KdX2MY2jV6EXfUs6scSfmC...";
let api_key_uid = "6062abda-a5aa-4414-ac91-ecd7944c0f8d";
let expires_at = time::macros::datetime!(2025 - 12 - 20 00:00:00 UTC);
let search_rules = json!({ "patient_medical_records": { "filter": "user_id = 1" } });

let token = client
.generate_tenant_token(api_key_uid, search_rules, api_key, expires_at)
.unwrap();
tenant_token_guide_search_sdk_1: |-
Comment on lines +1391 to +1399
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Replace concrete-looking keys and use a future expiration.

Line 1391–Line 1392 look like real secrets and are already flagged by secret scanning. Also, Line 1393 is in the past (December 20, 2025), so the sample token is immediately expired as of February 11, 2026. Please use obvious placeholders and a future date.

🔧 Suggested fix
-  let api_key = "B5KdX2MY2jV6EXfUs6scSfmC...";
-  let api_key_uid = "6062abda-a5aa-4414-ac91-ecd7944c0f8d";
-  let expires_at = time::macros::datetime!(2025 - 12 - 20 00:00:00 UTC);
+  let api_key = "MEILISEARCH_API_KEY";
+  let api_key_uid = "API_KEY_UID";
+  let expires_at = time::macros::datetime!(2026 - 12 - 20 00:00:00 UTC);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let api_key = "B5KdX2MY2jV6EXfUs6scSfmC...";
let api_key_uid = "6062abda-a5aa-4414-ac91-ecd7944c0f8d";
let expires_at = time::macros::datetime!(2025 - 12 - 20 00:00:00 UTC);
let search_rules = json!({ "patient_medical_records": { "filter": "user_id = 1" } });
let token = client
.generate_tenant_token(api_key_uid, search_rules, api_key, expires_at)
.unwrap();
tenant_token_guide_search_sdk_1: |-
let api_key = "MEILISEARCH_API_KEY";
let api_key_uid = "API_KEY_UID";
let expires_at = time::macros::datetime!(2026 - 12 - 20 00:00:00 UTC);
let search_rules = json!({ "patient_medical_records": { "filter": "user_id = 1" } });
let token = client
.generate_tenant_token(api_key_uid, search_rules, api_key, expires_at)
.unwrap();
tenant_token_guide_search_sdk_1: |-
🧰 Tools
🪛 Gitleaks (8.30.0)

[high] 1391-1391: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 1392-1392: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🤖 Prompt for AI Agents
In @.code-samples.meilisearch.yaml around lines 1391 - 1399, Replace the
concrete-looking secret values and past expiration with clear placeholders and a
future date: update the variables api_key and api_key_uid to non-sensitive
placeholder strings (e.g., "MEILISEARCH_API_KEY" and "API_KEY_UID_PLACEHOLDER")
and set expires_at to a date well in the future (e.g., 2030-01-01T00:00:00Z)
before calling client.generate_tenant_token(api_key_uid, search_rules, api_key,
expires_at). Ensure the token generation call and variable names (api_key,
api_key_uid, expires_at, client.generate_tenant_token) remain unchanged so
samples continue to demonstrate usage without exposing secrets.

let front_end_client = Client::new("http://localhost:7700", Some(token));
let results: SearchResults<Patient> = front_end_client
.index("patient_medical_records")
.search()
.with_query("blood test")
.execute()
.await
.unwrap();
Comment on lines +1400 to +1407
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Define token locally to keep the snippet standalone.

token is used without a local definition. If this snippet is rendered independently, it won’t compile or be copy‑pasteable. Consider adding a placeholder token in this block.

🧩 Suggested fix
+  let token = "TENANT_TOKEN";
   let front_end_client = Client::new("http://localhost:7700", Some(token));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let front_end_client = Client::new("http://localhost:7700", Some(token));
let results: SearchResults<Patient> = front_end_client
.index("patient_medical_records")
.search()
.with_query("blood test")
.execute()
.await
.unwrap();
let token = "TENANT_TOKEN";
let front_end_client = Client::new("http://localhost:7700", Some(token));
let results: SearchResults<Patient> = front_end_client
.index("patient_medical_records")
.search()
.with_query("blood test")
.execute()
.await
.unwrap();
🤖 Prompt for AI Agents
In @.code-samples.meilisearch.yaml around lines 1400 - 1407, The snippet uses
token without defining it, so make the example standalone by declaring a local
placeholder token before creating front_end_client: add a local variable (e.g.,
token) assigned to a placeholder string and use that when calling
Client::new("http://localhost:7700", Some(token)); keep all other symbols
(front_end_client, Client::new, SearchResults<Patient>,
index("patient_medical_records"), .search()) unchanged so the example compiles
and can be copy‑pasted.

multi_search_1: |-
let movie = client.index("movie");
let movie_ratings = client.index("movie_ratings");
Expand Down
Loading