kubernetes/kops · error

failed on file asset: %s is invalid, unable to decode base64

Error message

failed on file asset: %s is invalid, unable to decode base64, error: %q

What it means

FileAssetsBuilder.buildFileAssets wraps a base64.DecodeString failure when a file asset is marked as requiring base64 decoding (IsBase64/encoding set) but its Content is not valid base64. It names the offending asset path and echoes the decode error; the cluster spec's fileAssets content must be corrected or the base64 flag removed.

Source

Thrown at nodeup/pkg/model/file_assets.go:70

func (f *FileAssetsBuilder) buildFileAssets(c *fi.NodeupModelBuilderContext, assets []kops.FileAssetSpec, tracker map[string]bool) error {
	for _, asset := range assets {
		// @check if e have a path and if not use the default path
		assetPath := asset.Path
		if assetPath == "" {
			assetPath = filepath.Join(f.FileAssetsDefaultPath(), asset.Name)
		}
		// @check if the file has already been done and skip
		if _, found := tracker[assetPath]; found {
			continue
		}
		tracker[assetPath] = true // update the tracker

		// @check is the contents requires decoding
		content := asset.Content
		if asset.IsBase64 {
			decoded, err := base64.RawStdEncoding.DecodeString(content)
			if err != nil {
				return fmt.Errorf("failed on file asset: %s is invalid, unable to decode base64, error: %q", asset.Name, err)
			}
			content = string(decoded)
		}

		// If not specified, the default Mode is 0440
		if asset.Mode == "" {
			asset.Mode = "0440"
		}

		// We use EnsureTask so that we don't have to check if the asset directories have already been done
		c.EnsureTask(&nodetasks.File{
			Path: filepath.Dir(assetPath),
			Type: nodetasks.FileType_Directory,
			Mode: s("0755"),
		})

		c.AddTask(&nodetasks.File{
			Contents: fi.NewStringResource(content),

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Fix the base64 data in the cluster spec file asset
  2. Remove trailing whitespace/newlines from the base64 string
  3. Drop base64 encoding if content is plain text
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nodeup/pkg/model/file_assets.go:70 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/e956f28b0a6f55f6. Report an issue: GitHub.