Skip to content

fix(public-api): use correct SearchTime enum values in /search/posts#3898

Merged
capJavert merged 3 commits into
mainfrom
fix/public-api-search-posts-time-map
May 21, 2026
Merged

fix(public-api): use correct SearchTime enum values in /search/posts#3898
capJavert merged 3 commits into
mainfrom
fix/public-api-search-posts-time-map

Conversation

@capJavert
Copy link
Copy Markdown
Contributor

What

Fixes the time= query parameter on GET /public/v1/search/posts. The route's TIME_MAP was emitting DAY/WEEK/MONTH/YEAR/ALL but the GraphQL SearchTime enum (in src/schema/search.ts) is Today/LastSevenDays/LastThirtyDays/ThisYear/AllTime.

Result: every authenticated request to /public/v1/search/posts that included time= returned a 500.

Repro

curl -H "Authorization: Bearer <PAT>" \
  "https://api.daily.dev/public/v1/search/posts?q=foo&time=week"

GraphQL error (from SignOz logs):

Variable "$time" got invalid value "WEEK"; Value "WEEK" does not exist in "SearchTime" enum.

Mapping

Public API value GraphQL enum
day Today
week LastSevenDays
month LastThirtyDays
year ThisYear
all AllTime

The enum has a few more values (Yesterday, LastMonth, LastYear) that aren't exposed publicly. The 5-value public surface matches the route's querystring.enum definition above.

Discovery

Found while monitoring /public/v1 5xx during the daily.dev hackathon. Several participants hit this route with time=week and got 500s. Without time= the endpoint works (it falls through to null).

Tests

No new tests — the existing /search/posts test is describe.skip(...) because it requires mocking Mimir. This fix is a pure string mapping change; the GraphQL schema is the source of truth.

The TIME_MAP in src/routes/public/search.ts was emitting DAY/WEEK/MONTH/
YEAR/ALL but the GraphQL SearchTime enum (src/schema/search.ts) is
Today/LastSevenDays/LastThirtyDays/ThisYear/AllTime/Yesterday/LastMonth/
LastYear.

Result: every `GET /public/v1/search/posts?time=…` returned a 500 with
the GraphQL error 'Variable "$time" got invalid value "WEEK"; Value
"WEEK" does not exist in "SearchTime" enum.'

Confirmed via SignOz traces during the daily.dev hackathon — multiple
participants hit this.
@pulumi
Copy link
Copy Markdown

pulumi Bot commented May 21, 2026

🍹 The Update (preview) for dailydotdev/api/prod (at ad01535) was successful.

✨ Neo Explanation

Routine deployment of a bug fix that resolves 500 errors on `GET /public/v1/search/posts?time=…` by correcting invalid GraphQL enum values in `TIME_MAP`; all infrastructure changes are image tag bumps and migration job rotation. ✅ Low Risk

This is a standard application deployment rolling out commit ad01535 (from fc97c13). The TIME_MAP bug fix — correcting the SearchTime GraphQL enum values from invalid uppercase strings (DAY, WEEK) to valid ones (Today, LastSevenDays, etc.) — is the functional change being shipped. All Deployments and CronJobs are updated solely to point to the new container image tag. The migration Jobs follow the normal pattern of creating new versioned Jobs and deleting the previous ones.

Resource Changes

    Name                                                    Type                           Operation
~   vpc-native-update-tag-materialized-views-cron           kubernetes:batch/v1:CronJob    update
-   vpc-native-api-clickhouse-migration-fc97c13f            kubernetes:batch/v1:Job        delete
~   vpc-native-update-achievement-rarity-cron               kubernetes:batch/v1:CronJob    update
~   vpc-native-sync-subscription-with-cio-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-materialize-monthly-best-post-archives-cron  kubernetes:batch/v1:CronJob    update
~   vpc-native-user-profile-analytics-clickhouse-cron       kubernetes:batch/v1:CronJob    update
~   vpc-native-channel-highlights-cron                      kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-expired-better-auth-sessions-cron      kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-users-cron                      kubernetes:batch/v1:CronJob    update
~   vpc-native-update-trending-cron                         kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-images-cron                     kubernetes:batch/v1:CronJob    update
~   vpc-native-post-analytics-history-day-clickhouse-cron   kubernetes:batch/v1:CronJob    update
~   vpc-native-generate-search-invites-cron                 kubernetes:batch/v1:CronJob    update
+   vpc-native-api-db-migration-5a0eae23                    kubernetes:batch/v1:Job        create
~   vpc-native-personalized-digest-deployment               kubernetes:apps/v1:Deployment  update
~   vpc-native-deployment                                   kubernetes:apps/v1:Deployment  update
~   vpc-native-expire-super-agent-trial-cron                kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-stale-user-transactions-cron           kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-gifted-plus-cron                       kubernetes:batch/v1:CronJob    update
~   vpc-native-personalized-digest-cron                     kubernetes:batch/v1:CronJob    update
~   vpc-native-squad-posts-analytics-refresh-cron           kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-old-notifications-cron                 kubernetes:batch/v1:CronJob    update
~   vpc-native-materialize-yearly-best-post-archives-cron   kubernetes:batch/v1:CronJob    update
~   vpc-native-channel-digests-cron                         kubernetes:batch/v1:CronJob    update
~   vpc-native-hourly-notification-cron                     kubernetes:batch/v1:CronJob    update
~   vpc-native-temporal-deployment                          kubernetes:apps/v1:Deployment  update
~   vpc-native-calculate-top-readers-cron                   kubernetes:batch/v1:CronJob    update
~   vpc-native-bg-deployment                                kubernetes:apps/v1:Deployment  update
~   vpc-native-check-analytics-report-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-opportunities-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-rotate-daily-quests-cron                     kubernetes:batch/v1:CronJob    update
~   vpc-native-update-tags-str-cron                         kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-user-companies-cron             kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-channel-highlights-cron                kubernetes:batch/v1:CronJob    update
~   vpc-native-worker-job-deployment                        kubernetes:apps/v1:Deployment  update
~   vpc-native-update-current-streak-cron                   kubernetes:batch/v1:CronJob    update
~   vpc-native-rotate-weekly-quests-cron                    kubernetes:batch/v1:CronJob    update
~   vpc-native-user-posts-analytics-refresh-cron            kubernetes:batch/v1:CronJob    update
~   vpc-native-update-source-public-threshold-cron          kubernetes:batch/v1:CronJob    update
~   vpc-native-daily-digest-cron                            kubernetes:batch/v1:CronJob    update
~   vpc-native-user-profile-updated-sync-cron               kubernetes:batch/v1:CronJob    update
... and 12 other changes

capJavert added 2 commits May 21, 2026 14:24
- nock the mimir /v1/search call (same pattern as recommend.ts tests)
- parametrized test for time=day|week|month|year|all to lock the
  TIME_MAP → SearchTime enum mapping
- 400 on unknown time value (schema enum validation)
- 401 without bearer token

Without the TIME_MAP fix in this PR, the parametrized cases all return
500 (Variable "$time" got invalid value …).
The app's global setErrorHandler in src/index.ts converts all errors
(including fastify schema validation errors) to 500, so the 400
expectation doesn't hold. Out of scope for this PR — the 5 parametrized
time= cases still cover the fix.
@capJavert capJavert merged commit 91997fe into main May 21, 2026
9 checks passed
@capJavert capJavert deleted the fix/public-api-search-posts-time-map branch May 21, 2026 14:55
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