pulumi/pulumi · error

only wrote %d/%d bytes of the schema

Error message

only wrote %d/%d bytes of the schema

What it means

`pulumi package extract-schema` verifies that the schema bytes it wrote to stdout were fully written; if the writer accepted fewer bytes than the buffer length it reports the short write.

Source

Thrown at pkg/cmd/pulumi/packagecmd/package_extract_schema.go:93

			defer contract.IgnoreClose(pctx)

			parameters := &plugin.ParameterizeArgs{Args: parameterArgs}
			spec, _, err := packages.SchemaFromSchemaSource(pkgWorkspace.Instance, pctx, source, parameters,
				registry, env.Global(), 0 /* unbounded concurrency */, asExtension, serverURL)
			if err != nil {
				return err
			}
			bytes, err := json.MarshalIndent(spec, "", "  ")
			if err != nil {
				return err
			}
			bytes = append(bytes, '\n')
			n, err := cmd.OutOrStdout().Write(bytes)
			if err != nil {
				return err
			}
			if len(bytes) != n {
				return fmt.Errorf("only wrote %d/%d bytes of the schema", len(bytes), n)
			}

			// Also try to bind the schema to warn about any diagnostics:
			_, err = packages.BindSpec(*spec, schema.NewPluginLoader(pctx))
			if err != nil {
				return fmt.Errorf("failed to bind schema: %w", err)
			}

			return nil
		},
	}

	constrictor.AttachArguments(cmd, &constrictor.Arguments{
		Arguments: []constrictor.Argument{
			{Name: "schema-source"},
			{Name: "provider-parameter"},
		},
		Required: 1,

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Write the schema to a file (check for an --out/-o option) instead of piping
  2. Ensure the downstream consumer reads all output before exiting
  3. Check destination disk space and descriptor health

Example fix

// before
pulumi package extract-schema provider | head
// after
pulumi package extract-schema provider > schema.json
Defensive patterns

Strategy: fallback

Validate before calling

# write to file and verify size instead of piping
pulumi package extract-schema <provider> > schema.json && [ -s schema.json ]

Try / catch

if ! pulumi package extract-schema "$p" > schema.json; then echo "short write or stream failure; redirect to a file instead"; exit 1; fi

Prevention

When it happens

Trigger: cmd.OutOrStdout().Write returns n < len(bytes): output stream closed early (broken pipe) or a partial write on a failing descriptor.

Common situations: Piping output into a consumer that exits early (head/grep -q), stdout redirected to a full disk or network file that truncates.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/2301a7cd0619eb15. Report an issue: GitHub.