Skip to content

Conversation

@nios-x
Copy link
Contributor

@nios-x nios-x commented Dec 29, 2025

Proposed change

Resolves #3052

Contributor: Soumya (GitHub: @nios-x)
Role: Student contributor (GSoC aspirant)

This PR fixes an issue on the Board page where the UI enters an infinite loading state when the GraphQL response for a selected year returns null.

Previously, the loading state was rendered before validating whether boardOfDirectors data existed. As a result, when the query completed successfully but returned null, the page remained stuck on the loading spinner.

This change updates the conditional rendering logic to:

  • Check for null board data before rendering the loading state
  • Display a proper 404-style error message when board data is not available
  • Ensure the loading spinner is shown only while the query is actively loading

Checklist

  • Required: I read and followed the contributing guidelines
  • Required: I ran make check-test locally and all tests passed
  • I used AI for code, documentation, or tests in this PR

Previous ScreenShots:
image

Current ScreenShots
Screenshot 2025-12-29 195452

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Loading now relies on the central fetch status instead of a local flag, reducing race conditions and preventing premature UI rendering.
    • Error handling consistently surfaces request errors without depending on a separate local loading state.
  • UI/UX Improvements

    • Displays a loading spinner while data is being fetched for clearer feedback.
    • Ensures stable display of candidate sections and related UI during data population.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Replaced a local isLoading state with the loading flag from useQuery in the Board candidates page; moved candidate population to an effect that reads graphQLData.boardOfDirectors; removed all setIsLoading calls; render now returns LoadingSpinner based on loading.

Changes

Cohort / File(s) Summary
Board candidates page
frontend/src/app/board/[year]/candidates/page.tsx
Removed local isLoading state and its setters; destructured loading from useQuery(GetBoardCandidatesDocument); populated candidates from graphQLData.boardOfDirectors inside an effect; removed setIsLoading(false) calls; replaced isLoading render-guard with loading; kept existing GraphQL error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: addressing the infinite loader issue when board data is null and replacing it with an error state.
Description check ✅ Passed The description clearly explains the bug, the fix, and includes screenshots demonstrating the resolution, all directly related to the changeset.
Linked Issues check ✅ Passed The PR successfully implements the objective from issue #3052 by reordering conditional rendering to check for null board data before the loading state, displaying a 404-style error instead of infinite loader.
Out of Scope Changes check ✅ Passed All changes are scoped to the specific component and directly address the conditional rendering logic outlined in issue #3052; no extraneous modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ef00fb and 276a2f6.

📒 Files selected for processing (1)
  • frontend/src/app/board/[year]/candidates/page.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/app/board/[year]/candidates/page.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f85aa73 and 69cf133.

📒 Files selected for processing (1)
  • frontend/src/app/board/[year]/candidates/page.tsx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-31T13:47:15.861Z
Learnt from: rudransh-shrivastava
Repo: OWASP/Nest PR: 2155
File: frontend/src/server/queries/programsQueries.ts:81-81
Timestamp: 2025-08-31T13:47:15.861Z
Learning: In frontend/src/server/queries/programsQueries.ts, GET_PROGRAM_DETAILS is actively used in frontend/src/app/my/mentorship/programs/[programKey]/edit/page.tsx for program editing functionality and cannot be removed. It serves a different purpose than GET_PROGRAM_ADMIN_DETAILS, providing comprehensive program information needed for editing.

Applied to files:

  • frontend/src/app/board/[year]/candidates/page.tsx
🔇 Additional comments (3)
frontend/src/app/board/[year]/candidates/page.tsx (3)

675-692: Core fix looks good — conditional order correctly addresses the infinite loader bug.

The reordering ensures:

  1. Show spinner only while loading is true (active query)
  2. Handle errors when loading completes with an error
  3. Show 404 when data is null/unavailable

This correctly fixes the issue where the spinner would persist indefinitely when boardOfDirectors was null.


513-524: LGTM — className template adjustments.

These are minor formatting changes to the template literal concatenation pattern. No functional changes.

Also applies to: 548-559


635-670: LGTM — "Additional Information" section reorganization.

The section is now consolidated with consistent structure and styling. The logic remains the same, displaying status tags for OWASP board members, former staff, and GSoC mentors, with the flagship project note rendered conditionally.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
frontend/src/app/board/[year]/candidates/page.tsx (2)

90-90: Dead code: Remove unused isLoading state.

The isLoading state variable is no longer used since the component now relies on the loading flag from useQuery (line 676). This state and its setter at line 103 should be removed.


96-99: Duplicate error handling creates poor user experience.

The error is handled here with handleAppError(graphQLRequestError), which likely shows a toast notification. However, the render path at lines 680-682 then returns null, leaving the user with a blank screen and only a toast message. This was already flagged in previous review comments.

A better approach would be to remove the error handling from the useEffect entirely and show an <ErrorDisplay> component in the render path (similar to the 404 case at lines 684-692), providing a more informative error page.

🔎 Suggested approach

Remove error handling from useEffect:

  useEffect(() => {
-   if (graphQLRequestError) {
-     handleAppError(graphQLRequestError)
-     return
-   }
-
    if (graphQLData?.boardOfDirectors) {
      setCandidates(graphQLData.boardOfDirectors.candidates || [])
-     setIsLoading(false)
    }
- }, [graphQLData, graphQLRequestError])
+ }, [graphQLData])

Then update the render path to show ErrorDisplay:

  if (graphQLRequestError) {
-   return null
+   handleAppError(graphQLRequestError)
+   return (
+     <ErrorDisplay
+       statusCode={500}
+       title="Failed to load board candidates"
+       message="An error occurred while fetching the board information. Please try again later."
+     />
+   )
  }
🧹 Nitpick comments (2)
frontend/src/app/board/[year]/candidates/page.tsx (2)

514-560: Stylistic improvement: Consolidated className templates.

The className formatting has been updated to use template literals with ternary operators, which is more concise than the previous approach. This is a stylistic improvement with no functional changes.


636-671: Improved structure: Consolidated Additional Information section.

The Additional Information section has been restructured for better consistency and readability. The conditional rendering logic remains the same, but the layout is now cleaner and more maintainable.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69cf133 and 480bd4b.

📒 Files selected for processing (1)
  • frontend/src/app/board/[year]/candidates/page.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/app/board/[year]/candidates/page.tsx (2)
frontend/src/types/__generated__/boardQueries.generated.ts (1)
  • GetBoardCandidatesDocument (33-33)
frontend/src/app/global-error.tsx (1)
  • handleAppError (67-91)
🔇 Additional comments (3)
frontend/src/app/board/[year]/candidates/page.tsx (3)

92-92: Good addition: Using loading from useQuery.

Capturing the loading flag from useQuery is the correct approach to fix the infinite loading issue. This enables proper loading state management based on the actual query status rather than local state.


676-678: Core fix: Loading state correctly managed.

This is the key fix that resolves the infinite loading issue described in the PR objectives. By checking the loading flag from useQuery directly, the spinner only displays while the query is actively loading, preventing the infinite loading state when data is null.


684-692: Correct 404 handling for missing data.

The 404 error display is correctly shown when boardOfDirectors data doesn't exist for the selected year. This provides clear feedback to the user about why the data isn't available, which aligns with the PR objectives.

@nios-x
Copy link
Contributor Author

nios-x commented Dec 29, 2025

Hey @arkid15r. There was a minor bug which was not soo important to fix. But i closed that pr worked on that bug fixed it and now you can see there is now.

@nios-x
Copy link
Contributor Author

nios-x commented Dec 29, 2025

compressed.mp4

@nios-x
Copy link
Contributor Author

nios-x commented Dec 29, 2025

Everything is working fine as the video explains it. You can further see the code changes.
Thanks for understanding and for your valuable time maintainers 😊😊

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

@nios-x thanks for working on this.
You need to first address CodeRabbit comments and get approval from it.
Also, there's 1 new Sonar issue introduced in this PR - you need to fix that before we review 👌🏼

@nios-x nios-x closed this Dec 30, 2025
@kasya
Copy link
Collaborator

kasya commented Dec 30, 2025

@nios-x please do not close PRs the have requested changes - address all comments in this PR. I will close a duplicate if it's open.

@arkid15r
Copy link
Collaborator

Screenshot 2025-12-30 at 11 46 11 AM

🤷‍♂️

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 1, 2026
@nios-x nios-x requested a review from kasya January 1, 2026 18:30
@nios-x
Copy link
Contributor Author

nios-x commented Jan 1, 2026

So what i do next

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 2, 2026

@kasya
Copy link
Collaborator

kasya commented Jan 2, 2026

So what i do next

@nios-x next you should read our guidelines more closely https://github.com/OWASP/Nest/blob/main/CONTRIBUTING.md#contributing-workflow

I will address issues with this PR. For example - you did not run make check-test before pushing your last changes. So checks are failing. I feel like with the way this PR is going it's just easier and faster for me to finish this up.
Screenshot 2026-01-01 at 4 23 41 PM

If you're considering contributing to OWASP Nest in the future I highly recommend you familiarizing yourself with our rules - it would be easier for you and for us.

p.s. we are not enforcing that but you might want to create separate branches for tasks you're working on. It's not a good practice to work straight from main branch. Just an advice 👌🏼

@kasya kasya enabled auto-merge January 2, 2026 00:41
@kasya kasya added this pull request to the merge queue Jan 2, 2026
Merged via the queue into OWASP:main with commit 495e2fc Jan 2, 2026
25 checks passed
@nios-x
Copy link
Contributor Author

nios-x commented Jan 2, 2026

Thanks @kasya and @arkid15r for the review and for merging this.
I learned a lot about the OWASP workflow, checks, and review expectations.
I’ll make sure to follow the contributing guidelines more closely in future PRs 🙏

arkid15r pushed a commit that referenced this pull request Jan 2, 2026
…s null (#3084)

* fix(board): render error state instead of infinite loader when data is null

* Address make-check

---------

Co-authored-by: Kate <kate@kgthreads.com>
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.

Board page showed infinite loading when no data existed for a given year

3 participants