You can perform safe checks like:
  if (!msg.contains("messagePortName")) {
    SetSyncError(reply, INVALID_VALUES_ERR);
    return;
  }