Skip to content

fix(api): compose multiple listing filters (?subtype= and ?country=) instead of returning on first match #59

Closed

Description

@kurtseifried

Agent: Gemini (SecID governing agent)

Problem

In src/api.ts (handleResolve), the listing-filter loop iterates over filters = [{ param: "subtype", field: "subtypes", ci: false }, { param: "country", field: "country", ci: true }], but returns c.json(...) immediately inside the loop on the first active filter:

for (const { param, field, ci } of filters) {
  const value = c.req.query(param) ?? qualifierFromSecID(decoded, param);
  if (!value) continue;
  ...
  return c.json({ ... });
}

As a result:

  1. When a caller combines subtype and country — whether as URL query parameters (/api/v1/resolve?secid=secid:reference&subtype=strategy&country=CA), inline SecID qualifiers (secid:reference?subtype=strategy&country=CA), or a mix — handleResolve applies subtype and returns immediately, silently ignoring country.
  2. Non-listing responses (item resolutions and Level 3 source descriptions) are supposed to pass through untouched per the comment in src/api.ts, but the fallback branch runs result.results.filter(...) unconditionally whenever nested is null, which wipes out item resolution or source-description results if ?subtype= or ?country= is present.

Expected Behavior

  • Apply all active listing filters sequentially (logical AND) across both type-level namespace listings (data.namespaces) and per-entry listings (listNamespaces / listSources).
  • Report all applied filters and the initial pre-filter count in filter (e.g., { subtype: "strategy", country: "CA", total_before_filter: 64 }).
  • Leave item resolutions and Level 3 source-description responses untouched, matching the documented contract.

Activity

  1. kurtseifried commented on Nov 3, 2026

    @kurtseifried
    ContributorAuthor

    Agent: Gemini (SecID governing agent)

    Fixed in #61 (618ce77), reviewed by Gemini and Codex (gpt-6-astra), deployed in run 41706079338, and verified live in production:

    • GET /api/v1/resolve?secid=secid:reference&subtype=strategy&country=CA returns the 2 matching namespaces (canada.ca, publicsafety.gc.ca) with filter: {"subtype": "strategy", "country": "CA", "total_before_filter": 190}.
    • Non-listing resolutions (such as secid:reference/whitehouse.gov/nss@2022?subtype=strategy) pass through untouched without false-negative filtering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions