Skip to content

fix(follow): track success with boolean flag instead of reply.statusCode#153

Draft
anshul23102 wants to merge 1 commit into
Dev-Card:mainfrom
anshul23102:fix/follow-status-check
Draft

fix(follow): track success with boolean flag instead of reply.statusCode#153
anshul23102 wants to merge 1 commit into
Dev-Card:mainfrom
anshul23102:fix/follow-status-check

Conversation

@anshul23102
Copy link
Copy Markdown

Closes #148

What was wrong

In follow.ts, after calling followGitHub(), the code checked reply.statusCode to decide whether to log a success. However, Fastify initialises statusCode to 200 before any handler runs. The success path inside followGitHub() calls reply.send({ status: 'success', ... }) without setting a status code, so reply.statusCode stays at 200. The condition reply.statusCode === 200 || reply.statusCode === 204 therefore always evaluated to true, logging every follow attempt as a success even when it failed.

What changed

  • followGitHub() now returns Promise<boolean> - true only when GitHub responds with 204 No Content.
  • The caller uses that boolean to decide whether to write a success log entry.
  • reply.send() / reply.status().send() calls are no longer mixed with a statusCode check after the fact.

Type of change

  • Bug fix

reply.statusCode was checked after followGitHub() returned, but Fastify
sets statusCode to 200 by default before reply.send() is called with a
non-error body. This caused the follow log to always record 'success'
even when the request failed.

Fixed by returning a boolean from followGitHub() that is true only when
GitHub responds with 204, and using that to decide whether to log success.
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.

[bug] Follow success check uses reply.statusCode which is always 200 at that point — logs are wrong

1 participant