Skip to content

Fixed errors#228

Merged
sfreeman422 merged 6 commits intomasterfrom
fix/job-error
Mar 30, 2026
Merged

Fixed errors#228
sfreeman422 merged 6 commits intomasterfrom
fix/job-error

Conversation

@sfreeman422
Copy link
Copy Markdown
Collaborator

@sfreeman422 sfreeman422 commented Mar 30, 2026

  • Fixed defensive handling for empty/missing API responses in fun-fact.job.ts
  • Added Jest unit tests covering edge-case paths in fun-fact.job.spec.ts
  • Removed misleading .catch(...) wrapper in index.ts
  • Fixed @typescript-eslint/no-explicit-any lint error (replaced any with Record<string, unknown>)
  • Fixed Prettier formatting issue in fun-fact.job.spec.ts

Copilot AI review requested due to automatic review settings March 30, 2026 13:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves robustness of the backend “fun fact” scheduled job by adding defensive handling for unexpected/empty third-party API responses, and adds a scheduler-level catch around the job invocation.

Changes:

  • Add explicit checks for empty/missing payloads from API Ninjas, Quote API, and Wikipedia “On This Day” API.
  • Make Quote API parsing tolerant of missing nested fields and return an error payload when no quote is present.
  • Wrap the fun-fact cron invocation with a .catch(...) handler (though the current job implementation already catches internally).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/backend/src/jobs/fun-fact.job.ts Adds guards/early exits for empty or missing API response fields to avoid runtime crashes.
packages/backend/src/index.ts Adds a cron-level rejection handler for the fun-fact job invocation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sfreeman422 and others added 2 commits March 30, 2026 10:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

packages/backend/src/jobs/fun-fact.job.ts:151

  • The catch branch always returns error: 'Issue with quote API - non 200 status code', but Axios can throw for network/timeouts/other failures as well, so this message can be misleading. Consider using a more general error message and/or including the caught error details (e.g., for logging) so operational troubleshooting isn’t obscured.
    } catch {
      return { text: '', error: 'Issue with quote API - non 200 status code' };
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sfreeman422 and others added 2 commits March 30, 2026 11:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sfreeman422
Copy link
Copy Markdown
Collaborator Author

@copilot failing checks

Copy link
Copy Markdown

Copilot AI commented Mar 30, 2026

@copilot failing checks

Fixed in commit e8fd1d1. Two CI failures in fun-fact.job.spec.ts:

  1. @typescript-eslint/no-explicit-any — replaced (block: any) with (block: Record<string, unknown>) and updated the property access accordingly
  2. Prettier formatting — missing blank line before an it( block; fixed with prettier --write

@sfreeman422 sfreeman422 merged commit 57a5248 into master Mar 30, 2026
10 checks passed
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.

3 participants