Program: 142192
Project: 142192
Buggy source:
/** 
 * Reparse the saved form instance associated with the form record and apply any updates found to the form record, such as UUID and date modified, returning an updated copy.  Write the updated record to storage. If the record is associated with a case id, recompute and write the SessionStateDescriptor too.
 * @param context   Used to get the filepath of the form instanceassociated with the record.
 * @param oldRecord Reparse this record and return an updated copy of it
 * @param newStatus The new form record status
 * @param storage   User storage where updated FormRecord is written
 * @return The reparsed form record and the associated case id, if present
 * @throws IOException                       Problem opening the saved formattached to the record.
 * @throws InvalidStructureException         Occurs during reparsing of theform attached to record.
 * @throws XmlPullParserException
 * @throws UnfullfilledRequirementsException Parsing encountered a platformversioning problem
 */
public static FormRecord updateAndWriteRecord(Context context,CommCarePlatform platform,FormRecord oldRecord,String newStatus,SqlStorage<FormRecord> storage) throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException {
  Pair<FormRecord,String> recordUpdates=reparseRecord(context,oldRecord,newStatus);
  FormRecord updated=recordUpdates.first;
  String caseId=recordUpdates.second;
  if (caseId != null && FormRecord.STATUS_UNINDEXED.equals(oldRecord.getStatus()) && !FormRecord.STATUS_UNINDEXED.equals(newStatus)) {
    AndroidSessionWrapper asw=AndroidSessionWrapper.mockEasiestRoute(platform,oldRecord.getFormNamespace(),caseId);
    asw.setFormRecordId(updated.getID());
    SqlStorage<SessionStateDescriptor> ssdStorage=CommCareApplication._().getUserStorage(SessionStateDescriptor.class);
    try {
      ssdStorage.write(asw.getSessionStateDescriptor());
    }
 catch (    StorageFullException e) {
    }
  }
  storage.write(updated);
  return updated;
}

Fixed version (ground truth):
/** 
 * Reparse the saved form instance associated with the form record and apply any updates found to the form record, such as UUID and date modified, returning an updated copy with the status set to saved.  Write the updated record to storage.
 * @param context   Used to get the filepath of the form instanceassociated with the record.
 * @param oldRecord Reparse this record and return an updated copy of it
 * @param storage   User storage where updated FormRecord is written
 * @return The reparsed form record and the associated case id, if present
 * @throws IOException                       Problem opening the saved formattached to the record.
 * @throws InvalidStructureException         Occurs during reparsing of theform attached to record.
 * @throws XmlPullParserException
 * @throws UnfullfilledRequirementsException Parsing encountered a platformversioning problem
 */
public static FormRecord updateAndWriteRecord(Context context,FormRecord oldRecord,SqlStorage<FormRecord> storage) throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException {
  Pair<FormRecord,String> recordUpdates=reparseRecord(context,oldRecord);
  FormRecord updated=recordUpdates.first;
  String caseId=recordUpdates.second;
  if (caseId != null && FormRecord.STATUS_UNINDEXED.equals(oldRecord.getStatus())) {
    throw new RuntimeException("String_Node_Str");
  }
  storage.write(updated);
  return updated;
}