Repository: etcd-io/etcd
File: tests/robustness/report/client.go (Go)

Code before:
			ClientID int
			Input    model.EtcdRequest
			Call     int64
			Output   model.MaybeEtcdResponse
			Return   int64
		}
		err = decoder.Decode(&operation)
		if err != nil {
			return nil, fmt.Errorf("failed to decode KV operation, err: %w", err)
		}
		operations = append(operations, porcupine.Operation{
			ClientId: operation.ClientID,
			Input:    operation.Input,
			Call:     operation.Call,
			Output:   operation.Output,
			Return:   operation.Return,
		})
	}
	return operations, nil
}

func persistWatchOperations(lg *zap.Logger, path string, responses []model.WatchOperation) error {
	lg.Info("Saving watch operations", zap.String("path", path))
	file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755)
	if err != nil {
		return fmt.Errorf("Failed to save watch operations: %v", err)
	}
	defer file.Close()
	encoder := json.NewEncoder(file)
	for _, resp := range responses {
		err := encoder.Encode(resp)
		if err != nil {
			return fmt.Errorf("Failed to encode operation: %v", err)
		}
	}
	return nil
}

func persistKeyValueOperations(lg *zap.Logger, path string, operations []porcupine.Operation) error {
	lg.Info("Saving operation history", zap.String("path", path))
	file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755)
	if err != nil {
		return fmt.Errorf("Failed to save KV operation history: %v", err)
	}
	defer file.Close()
	encoder := json.NewEncoder(file)
	for _, op := range operations {
		err := encoder.Encode(op)
		if err != nil {
			return fmt.Errorf("Failed to encode KV operation: %v", err)
		}

Review comment (suggestion):
This makes sense, however we need to lowercase the error message as the static validation will requires it.

Code after:
			ClientID int
			Input    model.EtcdRequest
			Call     int64
			Output   model.MaybeEtcdResponse
			Return   int64
		}
		err = decoder.Decode(&operation)
		if err != nil {
			return nil, fmt.Errorf("failed to decode KV operation, err: %w", err)
		}
		operations = append(operations, porcupine.Operation{
			ClientId: operation.ClientID,
			Input:    operation.Input,
			Call:     operation.Call,
			Output:   operation.Output,
			Return:   operation.Return,
		})
	}
	return operations, nil
}

func persistWatchOperations(lg *zap.Logger, path string, responses []model.WatchOperation) error {
	lg.Info("Saving watch operations", zap.String("path", path))
	file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755)
	if err != nil {
		return fmt.Errorf("failed to save watch operations: %w", err)
	}
	defer file.Close()
	encoder := json.NewEncoder(file)
	for _, resp := range responses {
		err := encoder.Encode(resp)
		if err != nil {
			return fmt.Errorf("failed to encode operation: %w", err)
		}
	}
	return nil
}

func persistKeyValueOperations(lg *zap.Logger, path string, operations []porcupine.Operation) error {
	lg.Info("Saving operation history", zap.String("path", path))
	file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o755)
	if err != nil {
		return fmt.Errorf("Failed to save KV operation history: %w", err)
	}
	defer file.Close()
	encoder := json.NewEncoder(file)
	for _, op := range operations {
		err := encoder.Encode(op)
		if err != nil {
			return fmt.Errorf("Failed to encode KV operation: %w", err)
		}