Skip to content

fix: undefined xcpcio scoreboard team_id#1082

Merged
undefined-moe merged 1 commit into
hydro-dev:masterfrom
gtn1024:fix-sth
Nov 12, 2025
Merged

fix: undefined xcpcio scoreboard team_id#1082
undefined-moe merged 1 commit into
hydro-dev:masterfrom
gtn1024:fix-sth

Conversation

@gtn1024

@gtn1024 gtn1024 commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

Bug Fixes

  • Fixed team identification in contest submissions to ensure it correctly reflects the user's context for each submission record
  • Corrected a template rendering issue that was preventing the Scratchpad menu item from displaying properly in contest problems

Copilot AI review requested due to automatic review settings November 12, 2025 01:53
@coderabbitai

coderabbitai Bot commented Nov 12, 2025

Copy link
Copy Markdown

Walkthrough

Two distinct changes across the codebase: First, the submissionBase function in the scoreboard module now accepts an optional uid parameter, with updated logic to prioritize this parameter over rdoc.uid when determining the team ID. The call site in loadContestState was updated to pass i.uid. Second, a template syntax error in the problem sidebar partial was fixed by removing an extraneous closing tag from a Jinja2 conditional, correcting the Scratchpad menu item visibility logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the optional uid parameter is correctly threaded through from loadContestState to submissionBase and that the fallback logic (uid if provided, otherwise rdoc.uid) matches the intended behavior
  • Confirm the Jinja2 template syntax is now valid and the Scratchpad conditional renders as expected
  • Check that no other call sites of submissionBase are affected by the new optional parameter

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing an undefined team_id issue in the xcpcio scoreboard by adding an optional uid parameter to ensure proper team identification.
✨ 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: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b633f1 and ec8aa59.

📒 Files selected for processing (2)
  • packages/scoreboard-xcpcio/index.ts (2 hunks)
  • packages/ui-default/templates/partials/problem_sidebar_contest.html (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/scoreboard-xcpcio/index.ts (1)
packages/hydrooj/src/interface.ts (2)
  • Tdoc (253-292)
  • RecordDoc (212-216)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
packages/ui-default/templates/partials/problem_sidebar_contest.html (1)

11-11: LGTM! Template syntax error fixed.

The conditional now correctly opens the if statement without an extraneous closing tag, allowing the proper if-else-endif block structure to evaluate Scratchpad visibility.

packages/scoreboard-xcpcio/index.ts (3)

28-38: LGTM! Optional uid parameter correctly handles journal entries.

The addition of the optional uid parameter with fallback logic (uid || rdoc.uid) appropriately addresses the scenario where journal entries (tsdoc detail entries) may not have a uid field directly. The design maintains backward compatibility for call sites passing full RecordDoc objects.


63-63: LGTM! Correctly passes team context to submissionBase.

Passing i.uid explicitly ensures that each submission inherits the correct team ID from its parent team status document, fixing the undefined team_id issue. This aligns with the team creation logic at line 46 where team_id is also derived from the user document.


102-108: Original review concern is unfounded—code is correct.

RecordPayload mandatorily includes uid: number (not optional), and RecordDoc inherits this field. At lines 102 and 107, rdoc from the record/judge event is always a complete RecordDoc with uid defined. The fallback to rdoc.uid is safe and works as intended.


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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where team_id was undefined in the XCPCIO scoreboard due to journal entries (tsdoc detail entries) not having a uid property. The fix also removes an extraneous %} in a Jinja2 template.

  • Fixed template syntax error with extra %} in the scratchpad condition
  • Added optional uid parameter to submissionBase() function to handle cases where rdoc.uid may be undefined
  • Updated the call in loadContestState() to explicitly pass i.uid for journal entries

Reviewed Changes

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

File Description
packages/ui-default/templates/partials/problem_sidebar_contest.html Removed extraneous %} from Jinja2 conditional statement
packages/scoreboard-xcpcio/index.ts Fixed undefined team_id by adding optional uid parameter to submissionBase() and passing it explicitly for journal entries
Comments suppressed due to low confidence (2)

packages/scoreboard-xcpcio/index.ts:102

  • The submissionBase function is called without passing the uid parameter. When rdoc is a RecordDoc with a valid uid, this works. However, for consistency with the fix applied at line 63, and to ensure the same team_id logic is applied, consider passing the uid explicitly if available. If rdoc.uid might be undefined here as well, this call should be updated to pass the correct uid parameter.
                else realtime.submissions.push({ ...submissionBase(tdoc, rdoc), status: statusStr });

packages/scoreboard-xcpcio/index.ts:107

  • The submissionBase function is called without passing the uid parameter. When rdoc is a RecordDoc with a valid uid, this works. However, for consistency with the fix applied at line 63, and to ensure the same team_id logic is applied, consider passing the uid explicitly if available. If rdoc.uid might be undefined here as well, this call should be updated to pass the correct uid parameter.
                else pub.submissions.push({ ...submissionBase(tdoc, rdoc), status: isLocked ? 'PENDING' : statusStr });

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

@undefined-moe undefined-moe merged commit 15d5cef into hydro-dev:master Nov 12, 2025
13 of 14 checks passed
@gtn1024 gtn1024 deleted the fix-sth branch November 12, 2025 03:11
@coderabbitai coderabbitai Bot mentioned this pull request May 23, 2026
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