apache/beam · error

invalid input ID format

Error message

invalid input ID format

What it means

inputIdToIndex parses a transform's local input ID, which must be in the form "iN" where N is a numeric index (e.g. "i0", "i2"). If the ID lacks the "i" prefix the format contract is broken and this error is returned instead of guessing an index.

Solutions

  1. Fix the source of the pipeline proto so local input IDs follow the "iN" convention.
  2. Regenerate/re-marshal the pipeline with the same Beam version on both sides.
  3. If IDs come from external tooling, rename them to the "iN" form before unmarshaling.
Defensive patterns

Strategy: validation

Validate before calling

func validInputID(id string) bool { return strings.HasPrefix(id, "i") && func() bool { _, err := strconv.Atoi(id[1:]); return err == nil }() }

Type guard

func isIndexedInputID(id string) bool { return len(id) > 1 && id[0] == 'i' }

Try / catch

idx, err := inputIdToIndex(id)
if err != nil {
    return fmt.Errorf("unexpected local input id %q in state spec: %w", id, err)
}

Prevention

When it happens

Trigger: unmarshalKeyedValues encounters a state/keyed-value spec whose input ID does not start with 'i' — e.g. malformed or hand-edited pipeline proto, or an ID produced by a different numbering convention.

Common situations: Pipelines marshaled by incompatible or buggy runner/SDK versions whose local input naming differs; hand-crafted or corrupted model pipeline protos; tests feeding invalid IDs.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/de8776db927a835b. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/runtime/exec/translate.go:905

	for i := 0; i < len(ret); i++ {
		if key, ok := ordered[i]; ok {
			ret[i] = m[key]
		} else {
			ret[i] = m[unordered[k]]
			k++
		}
	}
	return ret
}

// inputIdToIndex converts a local input ID for a transform into an index. Use
// this to avoid relying on format details for input IDs.
//
// Currently, expects IDs in the format "iN" where N is the index. If the ID is
// in an invalid form, returns an error.
func inputIdToIndex(id string) (int, error) {
	if !strings.HasPrefix(id, "i") {
		return 0, errors.New("invalid input ID format")
	}
	return strconv.Atoi(strings.TrimPrefix(id, "i"))
}

// indexToInputId converts an index into a local input ID for a transform. Use
// this to avoid relying on format details for input IDs.
func indexToInputId(i int) string {
	return "i" + strconv.Itoa(i)
}

func unmarshalPort(data []byte) (Port, string, error) {
	var port fnpb.RemoteGrpcPort
	if err := proto.Unmarshal(data, &port); err != nil {
		return Port{}, "", err
	}
	return Port{
		URL: port.GetApiServiceDescriptor().GetUrl(),
	}, port.CoderId, nil

View on GitHub (pinned to 12126d8942)