Skip to content

Commit 890a6f7

Browse files
authored
Merge pull request #1990 from major/cleanup-dead-redactor
RSPEED-3297: remove dead rlsapi_v1 error redactor
2 parents e185102 + 9f39ad6 commit 890a6f7

2 files changed

Lines changed: 0 additions & 41 deletions

File tree

src/app/endpoints/rlsapi_v1.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66

77
import functools
8-
import re
98
import time
109
from datetime import UTC, datetime
1110
from typing import Annotated, Any, Optional, cast
@@ -84,9 +83,6 @@ class TemplateRenderError(Exception):
8483
OpenAIAPIStatusError,
8584
)
8685

87-
_PRIVATE_ERROR_BLOCK_PATTERN = re.compile(r"\bPRIVATE\b[^\r\n,;)]*", re.IGNORECASE)
88-
_SECRET_KEY_PATTERN = re.compile(r"\bsk-[A-Za-z0-9][A-Za-z0-9_-]*")
89-
9086

9187
infer_responses: dict[int | str, dict[str, Any]] = {
9288
200: RlsapiV1InferResponse.openapi_response(),
@@ -103,23 +99,6 @@ class TemplateRenderError(Exception):
10399
}
104100

105101

106-
def _redact_sensitive_error_text(error_text: str) -> str:
107-
"""Redact sensitive substrings from backend error text before telemetry.
108-
109-
Backend exceptions can include provider request snippets or credentials in
110-
their string representation. Splunk events need enough context to explain
111-
the failure, but they must not contain private prompt blocks or API keys.
112-
113-
Args:
114-
error_text: Raw exception string returned by ``str(error)``.
115-
116-
Returns:
117-
Error text with known sensitive substrings replaced by placeholders.
118-
"""
119-
redacted_text = _PRIVATE_ERROR_BLOCK_PATTERN.sub("PRIVATE [REDACTED]", error_text)
120-
return _SECRET_KEY_PATTERN.sub("sk-[REDACTED]", redacted_text)
121-
122-
123102
def _build_instructions(systeminfo: RlsapiV1SystemInfo) -> str:
124103
"""Build LLM instructions by rendering the system prompt as a Jinja2 template.
125104

tests/unit/app/endpoints/test_rlsapi_v1.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
_call_llm,
2929
_compile_prompt_template,
3030
_get_default_model_id,
31-
_redact_sensitive_error_text,
3231
_resolve_quota_subject,
3332
infer_endpoint,
3433
)
@@ -246,25 +245,6 @@ def test_build_instructions_no_customization(mocker: MockerFixture) -> None:
246245
assert result == constants.DEFAULT_SYSTEM_PROMPT
247246

248247

249-
@pytest.mark.parametrize(
250-
("error_text", "expected"),
251-
[
252-
(
253-
"APIStatusError: PRIVATE prompt sk-backend-secret failed",
254-
"APIStatusError: PRIVATE [REDACTED]",
255-
),
256-
(
257-
"provider rejected token sk-proj-secret_key with status 401",
258-
"provider rejected token sk-[REDACTED] with status 401",
259-
),
260-
],
261-
ids=["private_block", "secret_key"],
262-
)
263-
def test_redact_sensitive_error_text(error_text: str, expected: str) -> None:
264-
"""Test backend error text redaction removes prompt and key secrets."""
265-
assert _redact_sensitive_error_text(error_text) == expected
266-
267-
268248
# --- Test Jinja2 template rendering ---
269249

270250

0 commit comments

Comments
 (0)