Skip to content

/api/dts/enrich editor preview fails for Showcase templates (enrichForType has no showcase case) #172

Description

@jfberry

Summary

POST /api/dts/enrich returns unsupported webhook type: showcase for the showcase DTS type, so operators cannot live-preview or iterate Showcase templates in the config/DTS editor. Every other alert type previews fine.

Impact

Operator-side tooling only — the DTS editor's "enrich preview" feature. Live delivery and the test command are not affected (see below).

Explicitly NOT affected (these work — do not change them)

  • Live Showcase deliveryProcessShowcase (processor/cmd/processor/showcase.go:68), called from the webhook receiver (processor/internal/webhook/receiver.go:162).
  • !poracle-test showcaseprocessTestShowcase (processor/cmd/processor/test.go:297), a separate path that does not go through enrichForType.

Reproduction

POST /api/dts/enrich with {"type": "showcase", "webhook": <a showcase sample from fallbacks/testdata.json>, ...} → error unsupported webhook type: showcase.

Root cause

ProcessorService.enrichForType (processor/cmd/processor/enrich.go:41) dispatches non-derived types via a switch webhookType with cases for pokemon, raid, egg, quest, invasion, lure, nest, gym, fort_update, max_battlebut no case "showcase" — so it falls to default: return nil, fmt.Errorf("unsupported webhook type: %s", ...).

Meanwhile dtsAlias("showcase") (processor/internal/dtsmap/dtsmap.go:68) resolves to {WebhookType: "showcase", TemplateType: "showcase"} — so the type is declared but not dispatched. EnrichWebhook (processor/cmd/processor/enrich.go:155, which POST /api/dts/enrich calls via processor/internal/api/huma_dts_writes.go:375) therefore errors.

The enrichment logic already exists — it's just not wired into enrichForType

Both ProcessShowcase and processTestShowcase build the showcase enrichment the same way: enricher.Invasion(...) for the base pokéstop fields, an override base["pokestop_name"] = sc.Name, then InvasionTranslate + ShowcaseFocusTranslate for the per-language focus/leaderboard fields (see processTestShowcase at processor/cmd/processor/test.go:297, and ShowcaseFocusTranslate in processor/internal/enrichment/showcase.go).

Proposed fix

  1. Factor the showcase enrichment into a shared ps.enrichShowcase(raw, language, freshenStaleTime) (*enrichResult, error) returning templateType: "showcase".
  2. Add case "showcase": result, err = ps.enrichShowcase(...) to the enrichForType switch.
  3. Ideally have ProcessShowcase / processTestShowcase call the same shared method to remove the current duplication.

Cleanup enabled by the fix

The api-pack conformance test currently works around this gap with a mirror helper — enrichShowcaseForConformance in processor/cmd/processor/api_pack_conformance_test.go:157 (a duplicate of processTestShowcase's enrichment). Once enrichForType("showcase", ...) works, delete that helper and switch the test's showcase subtest to the standard enrichForType path (as every other type already uses).

Acceptance criteria

  1. POST /api/dts/enrich with a showcase sample returns a populated variable map (templateType: "showcase"; non-empty base incl. pokestop_name, showcasePresent, the showcase[] leaderboard entries, and focus fields).
  2. enrichForType("showcase", raw, "en", true) returns a non-error *enrichResult.
  3. api_pack_conformance_test.go drops enrichShowcaseForConformance and renders showcase via enrichForType, still passing.
  4. No change to live Showcase delivery or !poracle-test showcase behaviour.
  5. go build ./... && go vet ./... && go test -count=1 ./... && golangci-lint run ./... all green.

Scope note

Independent of the API delivery work (PR #171) — a pre-existing gap in the enrich-dispatch / editor-preview path, surfaced (not caused) by that PR's conformance test. Safe to do as its own PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions