Skip to content

Normalize tuple defaults on list fields instead of warning - #242

Merged
pufit merged 1 commit into
mainfrom
pufit/fix-langfuse-redact-default-type
Aug 1, 2026
Merged

Normalize tuple defaults on list fields instead of warning#242
pufit merged 1 commit into
mainfrom
pufit/fix-langfuse-redact-default-type

Conversation

@pufit

@pufit pufit commented Aug 1, 2026

Copy link
Copy Markdown
Member

Symptom

Since #205 (ced5afa, the list-field coercion), every config load logs:

[WARNING] nerve.coerce: LangfuseConfig.redact_patterns: ignoring non-list config value ('sk-ant-…', …), leaving it as-is

on any config that doesn't mention langfuse.redact_patterns — i.e. for most installs, on every nerve command and session.

Root cause

_DEFAULT_LANGFUSE_REDACT_PATTERNS is a module-level tuple, and LangfuseConfig.from_dict hands it through as the field default. _str_list deliberately passes non-lists untouched (so coerce_scalars can wrap a ${VAR} string as one element), but _scalar_to_list only knew None/str/scalars — a tuple fell through to the warn-and-skip branch. Harmless in effect (the consumer list()s the field, all four patterns still compiled), but pure noise on every load.

Fix

  • config.py: materialize the default as list(...) in from_dict, so the field arrives as its declared type. Same None-vs-[] semantics as before (a bare redact_patterns: keeps the defaults, an explicit [] turns redaction off).
  • coerce.py: teach _scalar_to_list to copy tuples element-wise. YAML never parses to a tuple, so one can only be a code-side default — the elements are already the intended entries, only the container is wrong.

Tests

  • A defaults sweep: from_dict({}) must yield an actual list for every declared list[X] field across all config dataclasses — the existing sweeps only fed values in and never checked what a builder produces when the section is absent, which is exactly how this slipped through. (DEFAULT_CLAUDE_MODELS is the only other tuple constant near a list field and is already list()-wrapped at its use site; the sweep now pins that class of bug.)
  • A targeted regression test: an absent langfuse block keeps the default redact set with zero nerve.coerce warnings.

Both fail on main, pass here. Full suite: 2940 passed.

Generated by Nerve

@pufit
pufit merged commit 94406ea into main Aug 1, 2026
2 checks passed
@pufit
pufit deleted the pufit/fix-langfuse-redact-default-type branch August 1, 2026 04:50
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.

1 participant