Skip to content

[deep-report] Consolidate pkg/parser map[string]any assertions to use pkg/typeutil Lookup helpers #65855

Description

@github-actions

Description

pkg/parser hand-writes the value.(map[string]any) type assertion 87 times across 14 non-test files (161 including tests), even though pkg/typeutil/lookup.go already provides LookupMap, LookupString, and LookupStringPath helpers with consistent, centralized error handling. Only pkg/parser/frontmatter_hash.go currently uses the shared helpers — every other call site duplicates the same ok-check-and-error-message boilerplate independently, so a future fix to one assertion's error message or nil-handling won't propagate to the other 86.

Highest-concentration files: schema_suggestions.go (15), mcp.go (12), import_field_extractor.go (10), import_schema_validation.go (9), yaml_import.go (6), tools_merger.go (6), schema_deprecation.go (6), import_observability.go (6), schema_triggers.go (5).

Example (pkg/parser/mcp.go:99):

mcpServers, ok := mcpServersSection.(map[string]any)
if !ok {
    return nil, fmt.Errorf("mcp-servers section must be a map, got %T. ...", mcpServersSection)
}

could become:

mcpServers, ok := typeutil.LookupMap(parentMap, "mcp-servers")

(adjusting call sites that assert on an already-extracted any value to instead look up from the parent map, or adding a typeutil.AsMap(value any) (map[string]any, bool) variant for that shape if needed).

Expected Impact

Removes ~87 duplicated assertion/error-handling blocks in the parser package, so future changes to map-lookup error messages or nil-safety only need to happen once in pkg/typeutil. Reduces review surface for pkg/parser changes and makes the existing typeutil helpers the single source of truth they were presumably designed to be.

Suggested Agent

New Agent (mechanical, file-by-file refactor with go build/go test ./pkg/parser/... verification after each file)

Estimated Effort

Medium (1-4 hours) — mechanical but touches 14 files; some call sites assert on an already-unwrapped any rather than a parent map key, so a small typeutil.AsMap helper may be needed for full coverage.

Data Source

DeepReport Intelligence Briefing analysis, 2026-10-05 (cycle 3), sourced from Typist: Go Type Consistency Analysis discussion (#65837).

Generated by 🔬 Deep Report · claude · agent · 282.7 AIC · ⌖ 7.05 AIC · ⊞ 7.1K · ◷

  • expires on Oct 7, 2026, 4:51 AM UTC-08:00

Activity

  1. github-actions commented on Oct 7, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-10-07T12:51:47.898Z.

    Closed by Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions