Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

conversion-gen generates code that leads to panics when fields are accessed after conversion #132883

Closed
Labels
kind/bugCategorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.
@sbueringer

Description

@sbueringer

What happened?

As the title says, conversion-gen has a bug that generates incorrect conversion code.

struct in the old apiVersion:

typeJSONSchemaPropsstruct {Items*JSONSchemaProps`json:"items,omitempty"`Propertiesmap[string]JSONSchemaProps`json:"properties,omitempty"`AllOf      []JSONSchemaProps`json:"allOf,omitempty"`ExclusiveMaximumbool`json:"exclusiveMaximum,omitempty"`}

struct in the new apiVersion: (ExclusiveMaximum was changed frombool to*bool)

typeJSONSchemaPropsstruct {Items*JSONSchemaProps`json:"items,omitempty"`Propertiesmap[string]JSONSchemaProps`json:"properties,omitempty"`AllOf      []JSONSchemaProps`json:"allOf,omitempty"`ExclusiveMaximum*bool`json:"exclusiveMaximum,omitempty"`}

Generated conversion code:

funcautoConvert_v1beta2_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in*v1beta2.JSONSchemaProps,out*JSONSchemaProps,s conversion.Scope)error {out.Items= (*JSONSchemaProps)(unsafe.Pointer(in.Items))out.Properties=*(*map[string]JSONSchemaProps)(unsafe.Pointer(&in.Properties))out.AllOf=*(*[]JSONSchemaProps)(unsafe.Pointer(&in.AllOf))iferr:=v1.Convert_Pointer_bool_To_bool(&in.ExclusiveMaximum,&out.ExclusiveMaximum,s);err!=nil {returnerr}returnnil}

Issue:
out.Items = (*JSONSchemaProps)(unsafe.Pointer(in.Items)) is wrong (similar forProperties andAllOf).
autoConvert_v1beta2_JSONSchemaProps_To_v1beta1_JSONSchemaProps should be called instead.

Accessing theExlusiveMaximum field after conversion leads to a panic.

Full example can be seen here:https://github.com/sbueringer/conversion-gen-panic-repro (just checkout and runmake test).

What did you expect to happen?

conversion-gen should generate correct code

How can we reproduce it (as minimally and precisely as possible)?

Full example can be seen here:https://github.com/sbueringer/conversion-gen-panic-repro (just checkout and runmake test).

Kubernetes version

conversion-gen v0.33.0

Related Slack thread:https://kubernetes.slack.com/archives/C0EG7JC6T/p1752170662367799 (but all relevant information is contained in this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp