Skip to content

autoDefaultFields's SEARCH_AUTO_EXCLUDED_TYPES guard is unreachable-effect — the positive allow-list below it already rejects every one of those types #6934

Description

@os-project-manager

Observation-class finding from #6897 (docs correction to content/docs/ui/views.mdx). Recorded, not claimed — filed unassigned, finding only, no pm:queue. Nothing a user hits today; no behaviour differs in either direction.

Fact (origin/main @ 6968885ef)

packages/spec/src/data/search-fields.tsautoDefaultFields filters the auto-default searchable set with a negative guard followed by a positive allow-list:

if (SEARCH_AUTO_EXCLUDED_FIELDS.has(f)) return false;
// …
if (SEARCH_AUTO_EXCLUDED_TYPES.has(t)) return false;      // line 72
return SEARCHABLE_TEXTUAL_TYPES.has(t) || SEARCHABLE_ENUM_TYPES.has(t);

The two sets are disjoint, so line 72 can never change the outcome:

  • SEARCH_AUTO_EXCLUDED_TYPES = json, object, grid, image, file, avatar, vector, location, geometry, secret, password, encrypted, boolean, lookup, master_detail
  • SEARCHABLE_TEXTUAL_TYPES = text, email, phone, url, autonumber, textarea, markdown
  • SEARCHABLE_ENUM_TYPES = select, status

Any type in the first set falls through the positive test as false anyway — identically to a type in none of the three sets (number, date, …). Delete line 72 and the resolved set is unchanged for every input.

What this is NOT

Why record it anyway

An unreachable-effect branch inside a live function reads as load-bearing to the next author: someone adding a new field type to SEARCHABLE_TEXTUAL_TYPES may reasonably believe they must also keep it out of SEARCH_AUTO_EXCLUDED_TYPES, when in fact only the positive list decides. That is the same shape as #6318 (retire the unreachable visibility-alias-deprecated rule) — code that cannot fire but still instructs readers.

Two defensible dispositions, and the choice is a judgment call for triage, not something to guess:

  1. Retire the line. Smallest diff; makes the positive allow-list visibly the single decider.
  2. Keep it and say so. Add one comment line stating it is redundant-by-construction defence-in-depth against a future edit that turns the positive test into a broader one — and, if kept, a pin asserting the two sets stay disjoint, so the redundancy is a checked fact rather than a coincidence.

I lean (1) for the same reason #6318 was accepted: a guard that cannot fire teaches a rule that does not exist. But this is genuinely cosmetic and it is correct for triage to close it as won't-fix.

Refs: #6897, #6675, #6318, ADR-0061, ADR-0049.


Generated by Claude Code

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions