ZhuLinsen/daily_stock_analysis · error · ValueError
{field_name} must not contain sensitive credentials
Error message
{field_name} must not contain sensitive credentials What it means
ValueError from DecisionSignalService._optional_identity_text (src/services/decision_signal_service.py:1228): optional identity-ish fields (e.g. ids/labels) are sanitized and then scanned for REDACTION_MARKERS; if any marker substring appears, the value is presumed to contain sensitive credentials and is rejected. This is a data-leak guard preventing tokens/keys from being persisted into decision-signal records.
Source
Thrown at src/services/decision_signal_service.py:1228
raise ValueError(f"{field_name} is required")
return None
text = sanitize_decision_signal_text(value)
if not text:
if required:
raise ValueError(f"{field_name} is required")
return None
if len(text) > max_length:
raise ValueError(f"{field_name} must be at most {max_length} characters")
return text
@classmethod
def _optional_identity_text(cls, value: Any, field_name: str, *, max_length: int) -> Optional[str]:
text = cls._optional_text(value, field_name, max_length=max_length)
if text is None:
return None
sanitized = sanitize_decision_signal_text(text)
if any(marker in sanitized for marker in REDACTION_MARKERS):
raise ValueError(f"{field_name} must not contain sensitive credentials")
return text
@staticmethod
def _optional_signal_text(value: Any) -> Optional[str]:
if value is None:
return None
if isinstance(value, (dict, list)):
return json.dumps(sanitize_decision_signal_payload(value), ensure_ascii=False, sort_keys=True)
text = sanitize_decision_signal_text(value)
return text or None
@staticmethod
def _optional_float(value: Any, field_name: str) -> Optional[float]:
if value in (None, ""):
return None
try:
return float(value)
except (TypeError, ValueError) as exc:View on GitHub (pinned to 5159bd72e8)
Solutions
- Strip credential-shaped content before sending: never forward raw headers, tokens, or redacted log lines into identity fields.
- If the marker hit is a false positive from innocuous text, rephrase the value to avoid the marker substring, and report the over-match to maintainers.
- Route structured secrets to dedicated secret storage (devkey/registry), never decision-signal fields.
- Add a pre-flight scan of payload text fields for marker substrings client-side.
Example fix
# before
label = f"retry-of-{failed_request_headers}" # contains 'Bearer eyJ...' → ValueError
service.create_signal({..., "label": label})
# after
label = f"retry-of-run-{run_id}"
service.create_signal({..., "label": label}) Defensive patterns
Strategy: validation
Validate before calling
from src.services.decision_signal_service import REDACTION_MARKERS
def clean_of_markers(text: str) -> str:
return text if not any(m in text for m in REDACTION_MARKERS) else ''
for field in ('label', 'trigger_source'):
if field in payload and not clean_of_markers(payload[field]):
del payload[field] # drop credential-tainted values before the call Type guard
def is_marker_free(text: str | None) -> bool:
return text is None or not any(marker in str(text) for marker in REDACTION_MARKERS) Prevention
- Never forward auth headers, tokens, or redacted log lines into signal text fields.
- Keep secrets in dedicated secret storage (devkey), reference by name only.
- If a marker false-positives on legitimate text, rephrase and report it to maintainers.
When it happens
Trigger: Passing a value that contains a redaction marker substring — typically text that itself looks like or contains credential material: 'sk-...', 'Bearer ...', 'api_key=...', 'password=', token fragments, or content already tagged by the sanitizer with a redaction placeholder like '[REDACTED]'. Because the check is substring-based, innocent text embedding a marker (e.g. a note quoting a log line 'Authorization: Bearer ***') also trips it.
Common situations: Debug payloads copy-pasting auth headers or .env fragments into a label field; upstream error messages that embed redacted secrets ('api_key=REDACTED') forwarded verbatim; over-broad marker matching flagging words that merely contain a marker substring; users pasting connector URLs with embedded tokens.
Related errors
- {field_name} must be an integer
- {field_name} must be positive
- unsupported_report_type
- terminal decision signal cannot be reactivated through statu
- score must be between 0 and 100
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/c563fbd235984db5.
Report an issue: GitHub.