Skip to content

bug: default naming for local object fails on cluster-scoped published resources #163

@rnwgnr

Description

@rnwgnr

Describe the bug

When a published resource is cluster-scoped, the default naming scheme {{ .Object.metadata.namespace | sha3short }}-{{ .Object.metadata.name | sha3short }} won't work cause sha3short requires a string input.
The local object will not be created.

Essentially this is not a bug but more of a convenience feature to have the defaults work in more usecases.

workaround:
Set a custom naming for the published resources, i.e.

spec:
  naming:
    name: "{{ .Object.metadata.name | sha3short }}"

Steps To Reproduce

  1. create a PublishedResource for a cluster-scoped object
  2. create APIExports and APIBindings
  3. create an instance of the resource
  4. check log entries in the api-syncagent primary pod
{"level":"error","time":"2026-04-30T06:06:01.526Z","logger":"syncagent-sync","caller":"controller/controller.go:495","msg":"Reconciler error","controller":"syncagent-sync","reconcileID":"a6c4a2ad-c31f-4d2b-99f3-179802f41453","error":"failed to create destination object: failed to create destination object: failed to generate local object name: invalid name naming: failed to evaluate: template: inline:1:32: executing \"inline\" at <sha3short>: invalid value; expected string"}

Expected Behaviour

The defaultNaming of local object works even for cluster-scoped published resources.

Additional Context

related source line:
https://github.com/kcp-dev/api-syncagent/blob/main/internal/sync/templating/naming.go#L53

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions