Skip to content

fix(ClassmateDataController): Missing component causes a server error - #373

Open
Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:fix/classmate-missing-component
Open

Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:fix/classmate-missing-component

Conversation

@Isaries

@Isaries Isaries commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Requests for classmate or peer-group work that name a node or component missing from the run's project are answered with HTTP 500. getProjectComponent() returns null in that case, and the ClassmateDataController subclasses read the result without checking, so they throw NullPointerException.

The client sends such a request for a Discussion whose connected component was left half configured in the authoring tool: the URL ends in /node2/null. The 500 leaves the Discussion empty for students, including their own earlier posts, and fills the server log with stack traces.

Changes

Each controller answers a missing component the way it already answers a component that does not qualify, so valid and wrong-type requests behave as before, and the check still runs after the run, period and peer-group authorization.

  • isComponentType(), used by ClassmateDiscussionDataController, and the component checks in ClassmateGraphDataController and PeerGroupWorkController treat it as a component of the wrong type and refuse the request with AccessDeniedException, as ClassmateSummaryDataController already does for a component not in the project.
  • PeerGroupStudentWorkAnnotationController returns an empty list, as it does when the referenced component is neither MultipleChoice nor OpenResponse. This covers both the requested component and the component it references.
  • No student work or annotations are looked up.

Test

  • New cases for a missing component or node in ClassmateDiscussionDataControllerTest, ClassmateGraphDataControllerTest, PeerGroupStudentWorkAnnotationControllerTest and a new PeerGroupWorkControllerTest. Against the current develop, all six fail with NullPointerException: Cannot invoke "ProjectComponent.getString(String)" because "projectComponent" is null or the equivalent. PeerGroupWorkControllerTest also pins the existing wrong-type response.
  • All Classmate* and PeerGroup* controller tests pass (76).

getProjectComponent() returns null when the run's project has no such
node or component, and the ClassmateDataController subclasses that
call it read the result without checking. A request naming a missing
component, such as the one the client sends for a Discussion whose
connected component has not been chosen yet (componentId "null"), threw
NullPointerException and was answered with HTTP 500.

Each controller now answers a missing component the way it already
answers a component that does not qualify. isComponentType(), which
ClassmateDiscussionDataController uses, and the component checks in
ClassmateGraphDataController and PeerGroupWorkController treat it as a
component of the wrong type, so the request is refused with
AccessDeniedException, as ClassmateSummaryDataController already does
for a component that is not in the project.
PeerGroupStudentWorkAnnotationController returns an empty list, as it
does when the referenced component is neither MultipleChoice nor
OpenResponse; this covers both the requested component and the component
it references. No student work or annotations are looked up.
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.

1 participant