Endpoint Seek Help If Issues

Endpoint seek_help_if Null Crash Report

Generated: 2026-03-31
Crash location: QuestionnairesManagementController::resetquestionnaire() — the line
$questionnaire = $code->endpoint->seek_help_if; followed by
$answer->questionnaire_id = $questionnaire->id; throws a null-pointer error when
the referenced questionnaire is soft-deleted (Eloquent returns null).


Summary

A total of 261 non-deleted endpoints have seek_help_if_questionnaire_id pointing to soft-deleted questionnaires. However, only 3 of those endpoints are actively assigned to non-deleted pathways — meaning only those 3 can realistically trigger the crash for live users.

Endpoint ID Endpoint Title Bad Questionnaire ID Pathway ID Pathway Title Junction Type
389 1-3d Improving (translation test) 3 301 getUBetter Internal testing Translation Test Area improving
390 1-3d Same (translation test) 3 301 getUBetter Internal testing Translation Test Area thesame
391 1-3d Worse (translation test) 3 301 getUBetter Internal testing Translation Test Area worse

Details

Questionnaire 3 (deleted 2026-02-25 08:14:20)

All 3 critical endpoints reference this soft-deleted questionnaire.

Pathway 301 — getUBetter Internal testing Translation Test Area

Endpoint ID Title Junction Table
389 1-3d Improving (translation test) imc_gap_pathway_endpoint_improving
390 1-3d Same (translation test) imc_gap_pathway_endpoint_thesame
391 1-3d Worse (translation test) imc_gap_pathway_endpoint_worse

Why the Other 258 Endpoints Are Not Immediately Dangerous

The remaining 258 bad endpoints exist in imc_gap_endpoint with broken seek_help_if_questionnaire_id values, but none of them appear (non-deleted) in any of the 4 pathway junction tables:

They cannot be reached via resetquestionnaire() because no live pathway routes users through them. They are still data hygiene issues but pose no immediate crash risk.


Recommended Fix

Option A — Quick fix (null-safe): Guard the crash in QuestionnairesManagementController::resetquestionnaire():

// Before (crashes):
$questionnaire = $code->endpoint->seek_help_if;
$answer->questionnaire_id = $questionnaire->id;

// After (safe):
$questionnaire = $code->endpoint->seek_help_if;
if (!$questionnaire) {
    // log or skip
    continue;
}
$answer->questionnaire_id = $questionnaire->id;

Option B — Data fix: For endpoints 389, 390, 391 — update seek_help_if_questionnaire_id to point to a valid (non-deleted) questionnaire, or set it to NULL if seek_help_if is not needed for the translation test pathway.

-- Set to null as a safe reset (or replace NULL with the correct questionnaire ID):
UPDATE imc_gap_endpoint
SET seek_help_if_questionnaire_id = NULL
WHERE id IN (389, 390, 391);