code: func populateAttemptedFields(am *authz2Model, challenge *corepb.Challenge) error {
  	if len(am.ValidationError) != 0 {
  		// If the error is non-empty the challenge must be invalid.
  		status := string(core.StatusInvalid)
  		challenge.Status = &status
  		var prob probs.ProblemDetails
  		err := json.Unmarshal(am.ValidationError, &prob)
  		if err != nil {
  			return badJSONError(
  				"failed to unmarshal authz2 model's validation error",
  				am.ValidationError,
  				err)
  		}
  		challenge.Error, err = grpc.ProblemDetailsToPB(&prob)
  		if err != nil {
  			return err
  		}
  	} else {
  		// If the error is empty the challenge must be valid.
  		status := string(core.StatusValid)
  		challenge.Status = &status
  	}
  	var records []core.ValidationRecord
  	err := json.Unmarshal(am.ValidationRecord, &records)
  	if err != nil {
  		return badJSONError(
  			"failed to unmarshal authz2 model's validation record",
  			am.ValidationRecord,
  			err)
  	}
  	challenge.Validationrecords = make([]*corepb.ValidationRecord, len(records))
  	for i, r := range records {
  		challenge.Validationrecords[i], err = grpc.ValidationRecordToPB(r)
  		if err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // populateAttemptedFields takes a challenge and populates it with the validation fields status,
  // validation records, and error (the latter only if the validation failed) from a authz2Model.