goharbor/harbor · error

failed to copy content to buffer: %w

Error message

failed to copy content to buffer: %w

What it means

Error "failed to copy content to buffer: %w" thrown in goharbor/harbor.

Source

Thrown at src/controller/artifact/processor/cnai/parser/util.go:92

		header, err := tr.Next()
		if err == io.EOF {
			break
		}

		if err != nil {
			return nil, fmt.Errorf("failed to read tar header: %w", err)
		}

		// skip the directory.
		if header.Typeflag == tar.TypeDir {
			continue
		}

		// Copy at most remaining+1 bytes so we can detect when the cumulative
		// content exceeds the limit without trusting the declared header size.
		n, err := io.Copy(&buf, io.LimitReader(tr, remaining+1))
		if err != nil {
			return nil, fmt.Errorf("failed to copy content to buffer: %w", err)
		}

		remaining -= n
		if remaining < 0 {
			return nil, errors.RequestEntityTooLargeError(errFileTooLarge)
		}
	}

	return buf.Bytes(), nil
}

// FileType represents the type of a file.
type FileType = string

const (
	TypeFile      FileType = "file"
	TypeDirectory FileType = "directory"
)

View on GitHub (pinned to 7b2fd08cc5)

When it happens

Trigger: Thrown at src/controller/artifact/processor/cnai/parser/util.go:92 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/a5ebfcac0ad8950a. Report an issue: GitHub.