Skip to content

🐛 Bug Report: ActivityFeed Response Schema Not Validated #505

@Tanayajadhav1

Description

@Tanayajadhav1

📜 Description

The ActivityFeed component fetches GitHub user events from the GitHub API but does not validate the response before using it. The code assumes the response always matches the expected EventType[] structure, which introduces runtime risk.
Currently, the API response is directly assigned to state without any validation or error handling

Problem:
This creates several reliability and safety issues:

  • Silent failures: Non-OK responses (400/403/404/500) are still parsed as JSON and used incorrectly
  • Runtime crashes: If response shape differs, accessing fields like event.repo?.name may break UI
  • Type safety bypass: TypeScript interfaces do not protect against invalid runtime API data
  • API unpredictability: GitHub API may change structure or rate-limit responses
  • Rate limit blindness: 403 rate limit responses and headers are not handled

Expected Behavior:
Before setting state, the application should:

  • Verify HTTP response success (res.ok)
  • Validate response structure matches EventType[ ]
  • Handle invalid or error responses gracefully
  • Show fallback UI when data is invalid or unavailable

Affected Files:
src/components/ActivityFeed.tsx
src/types/github.ts (optional)
src/utils/constants.ts (optional)

Suggested Implementation Approaches:
Option A: Manual Validation (No Dependencies)
Option B: Zod Validation

Suggested Labels:
gssoc'26,level:intermediate,bug,type:fix

What browsers are you seeing the problem on?

No response

📃 Relevant Screenshots (Links)

No response

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions