Skip to content

Fix TikTok stream worker TypeScript typing errors#154

Open
cvsz wants to merge 2 commits intomainfrom
codex/fix-typescript-build-errors
Open

Fix TikTok stream worker TypeScript typing errors#154
cvsz wants to merge 2 commits intomainfrom
codex/fix-typescript-build-errors

Conversation

@cvsz
Copy link
Copy Markdown
Owner

@cvsz cvsz commented Apr 4, 2026

Motivation

  • Resolve TypeScript errors caused by redis.xadd returning string | null and redis.xreadgroup returning unknown that prevented a clean build and could crash the worker loop.
  • Harden the TikTok stream worker so malformed Redis responses are skipped and do not stop the worker.

Description

  • Ensure enqueueTikTokWebhookEvent awaits redis.xadd into streamId, checks for a falsy result and throws Error if the stream ID is missing so the function always fulfills Promise<string>.
  • Add RedisStreamEntry and RedisStreamGroupResponse aliases and implement isRedisStreamGroupResponse runtime type guard to narrow the xreadgroup response safely.
  • Log and skip unexpected/malformed xreadgroup responses instead of iterating them, preventing runtime iteration errors.
  • Small refactor to iterate only validated stream entries before calling processStreamEntry.

Testing

  • Ran npm run build in app/ to validate TypeScript compilation and confirm the original TS2322 (string | null assignment) and TS2488 (unknown iteration) errors are resolved.
  • The npm run build command still fails in this environment due to unrelated missing dependencies/type declarations across the repository (external @types/node and other packages), so full project compilation is blocked but the targeted TikTok stream issues are fixed.

Codex Task

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the TikTok webhook enqueuing process to return the stream ID and introduces a type guard, isRedisStreamGroupResponse, to validate the structure of Redis stream responses before processing. A security concern was identified regarding the logging of the entire response object when validation fails, as it could lead to the exposure of sensitive information.

Comment thread app/src/services/tiktok.stream.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@cvsz cvsz self-assigned this Apr 4, 2026
@cvsz cvsz marked this pull request as draft April 4, 2026 06:58
@cvsz cvsz marked this pull request as ready for review April 29, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant