Skip to content

fix(stack): enforce max stack items and align public API limit#3578

Merged
rebelchris merged 4 commits intomainfrom
eng-696-adding-to-stack-fails-when-stack-has-50-items
Feb 13, 2026
Merged

fix(stack): enforce max stack items and align public API limit#3578
rebelchris merged 4 commits intomainfrom
eng-696-adding-to-stack-fails-when-stack-has-50-items

Conversation

@rebelchris
Copy link
Contributor

Summary

  • enforce a hard max stack size at MAX_STACK_ITEMS for both user and squad stack mutations
  • align the public stack REST endpoint limit with the same shared constant
  • add integration coverage for max-size behavior in GraphQL and public API tests

Key decisions

  • introduced a single shared constant (MAX_STACK_ITEMS = 100) to avoid drift between API layers
  • blocked add mutations once the current stack item count reaches the max, with explicit validation errors
  • made parseLimit accept an endpoint-specific max so stack endpoints can safely opt into higher limits without changing global defaults

Closes ENG-696


Created by Huginn 🐦‍⬛

@pulumi
Copy link

pulumi bot commented Feb 13, 2026

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

Resource Changes

    Name                                                       Type                           Operation
~   vpc-native-clean-gifted-plus-cron                          kubernetes:batch/v1:CronJob    update
~   vpc-native-update-trending-cron                            kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-stale-user-transactions-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-post-analytics-clickhouse-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-update-tag-recommendations-cron                 kubernetes:batch/v1:CronJob    update
~   vpc-native-validate-active-users-cron                      kubernetes:batch/v1:CronJob    update
~   vpc-native-user-profile-analytics-history-clickhouse-cron  kubernetes:batch/v1:CronJob    update
~   vpc-native-temporal-deployment                             kubernetes:apps/v1:Deployment  update
-   vpc-native-api-clickhouse-migration-04b17055               kubernetes:batch/v1:Job        delete
~   vpc-native-personalized-digest-cron                        kubernetes:batch/v1:CronJob    update
~   vpc-native-check-analytics-report-cron                     kubernetes:batch/v1:CronJob    update
~   vpc-native-generate-search-invites-cron                    kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-user-companies-cron                kubernetes:batch/v1:CronJob    update
~   vpc-native-update-highlighted-views-cron                   kubernetes:batch/v1:CronJob    update
~   vpc-native-update-source-public-threshold-cron             kubernetes:batch/v1:CronJob    update
~   vpc-native-generic-referral-reminder-cron                  kubernetes:batch/v1:CronJob    update
+   vpc-native-api-db-migration-f7d9c16d                       kubernetes:batch/v1:Job        create
~   vpc-native-update-source-tag-view-cron                     kubernetes:batch/v1:CronJob    update
~   vpc-native-daily-digest-cron                               kubernetes:batch/v1:CronJob    update
~   vpc-native-ws-deployment                                   kubernetes:apps/v1:Deployment  update
~   vpc-native-clean-zombie-opportunities-cron                 kubernetes:batch/v1:CronJob    update
~   vpc-native-bg-deployment                                   kubernetes:apps/v1:Deployment  update
~   vpc-native-personalized-digest-deployment                  kubernetes:apps/v1:Deployment  update
~   vpc-native-update-current-streak-cron                      kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-images-cron                        kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-users-cron                         kubernetes:batch/v1:CronJob    update
~   vpc-native-sync-subscription-with-cio-cron                 kubernetes:batch/v1:CronJob    update
~   vpc-native-calculate-top-readers-cron                      kubernetes:batch/v1:CronJob    update
~   vpc-native-user-profile-updated-sync-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-private-deployment                              kubernetes:apps/v1:Deployment  update
~   vpc-native-expire-super-agent-trial-cron                   kubernetes:batch/v1:CronJob    update
~   vpc-native-user-profile-analytics-clickhouse-cron          kubernetes:batch/v1:CronJob    update
-   vpc-native-api-db-migration-04b17055                       kubernetes:batch/v1:Job        delete
~   vpc-native-hourly-notification-cron                        kubernetes:batch/v1:CronJob    update
+   vpc-native-api-clickhouse-migration-f7d9c16d               kubernetes:batch/v1:Job        create
~   vpc-native-update-views-cron                               kubernetes:batch/v1:CronJob    update
~   vpc-native-post-analytics-history-day-clickhouse-cron      kubernetes:batch/v1:CronJob    update
~   vpc-native-user-posts-analytics-refresh-cron               kubernetes:batch/v1:CronJob    update
~   vpc-native-deployment                                      kubernetes:apps/v1:Deployment  update
~   vpc-native-update-tags-str-cron                            kubernetes:batch/v1:CronJob    update
... and 1 other changes

@rebelchris
Copy link
Contributor Author

@claude one of the tests is failing now, can you ensure all circleCI are green?

@claude
Copy link

claude bot commented Feb 13, 2026

Claude finished @rebelchris's task in 2m 59s —— View job


Unable to identify failing test

  • Check CircleCI status to identify failing test(s)
  • Read test files and implementation to understand the issue
  • Review code changes for potential issues

Analysis

I've thoroughly reviewed the PR changes and cannot identify a failing test. Here's what I found:

Code Changes Look Correct:

  1. MAX_STACK_ITEMS = 100 constant added to src/common/constants.ts
  2. parseLimit() function updated to accept optional maxLimit parameter (defaults to MAX_LIMIT = 50)
  3. ✅ Stack route updated to use parseLimit(request.query.limit, MAX_STACK_ITEMS)
  4. ✅ GraphQL resolvers updated with max count validation
  5. ✅ New tests added for max stack size enforcement

CI Status:

  • GitHub Actions: All workflows passing ✅
  • CircleCI: I cannot access the detailed CircleCI logs from this environment

Potential Issues Checked:

  • ✅ All other parseLimit() usages default correctly to MAX_LIMIT = 50
  • ✅ Test isolation - beforeEach doesn't interfere with new test
  • ✅ Type safety - no TypeScript errors apparent
  • ✅ Backward compatibility - existing endpoints unaffected

Next Steps

Could you provide:

  1. The specific test name that's failing in CircleCI
  2. The error message from the CircleCI logs
  3. Or a link to the failing CircleCI build

This will help me pinpoint the exact issue and fix it.

--- | Branch: eng-696-adding-to-stack-fails-when-stack-has-50-items

@rebelchris
Copy link
Contributor Author

@claude one test keeps failing:
POST /public/v1/feeds/custom should create a new custom feed

@claude
Copy link

claude bot commented Feb 13, 2026

Claude finished @rebelchris's task in 2m 28s —— View job


Test failure analysis

  • Read the failing test to understand what it's testing
  • Check how parseLimit() changes affect custom feeds endpoint
  • Analyze GitHub Actions CI status
  • Identify root cause from CircleCI logs

Findings

I've analyzed the PR changes and the test file. Here's what I found:

Code changes are correct:

  • The parseLimit() function now accepts an optional second parameter maxLimit with a default value of MAX_LIMIT (50)
  • This is backward compatible - all existing calls to parseLimit() without the second parameter will work as before
  • The custom feeds endpoints at src/routes/public/customFeeds.ts:313 and :390 call parseLimit(request.query.limit) without the second parameter, which is correct

CI Status:

  • ✅ GitHub Actions workflows are passing (CodeQL, Jira comment)
  • ❓ Cannot access detailed CircleCI logs from this environment

Possible causes:

  1. Test ordering/isolation issue: The new stack test creates 60 UserStack items. If there's a test isolation problem, this could affect subsequent tests
  2. Database state: The customFeeds test might be affected by leftover data from stack tests
  3. CircleCI-specific environment issue: Different test execution order or environment setup

Need your help

Could you please share:

  1. The specific error message from CircleCI for "POST /public/v1/feeds/custom should create a new custom feed"
  2. Or a link to the CircleCI build logs

This will help me pinpoint the exact failure and provide a fix. The code changes themselves appear correct, so the issue is likely environmental or test-ordering related.


View job | Branch: eng-696-adding-to-stack-fails-when-stack-has-50-items

@rebelchris rebelchris merged commit efe0f08 into main Feb 13, 2026
9 checks passed
@rebelchris rebelchris deleted the eng-696-adding-to-stack-fails-when-stack-has-50-items branch February 13, 2026 13:18
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