Skip to content

CustomProperty and DefaultValue of null value is allowed by the API but not the SDK (?) #3741

@ericmortebidbax

Description

@ericmortebidbax

I am not sure if this is a bug in the API, a missing piece of functionality in the SDK or if I am just misunderstanding something.

The API docs (https://docs.github.com/en/rest/orgs/org-properties?apiVersion=2022-11-28#create-a-custom-organization-property) indicates that default_value is not required.

But when creating a custom org property with required=true and no default_value, the API call gives me a "422 Validation failed: Default value must be present []"

curl -i -X PUT
'https://api.github.com/orgs/REDACTED/properties/schema/prov-test-create-property-basic'
-H 'Accept: application/vnd.github.v3+json'
-H 'Authorization: '
-H 'Content-Type: application/json'
-H 'User-Agent: go-github/v74.0.0'
-H 'X-Github-Api-Version: 2022-11-28'
-d '{"property_name":"prov-test-create-property-basic","value_type":"single_select","required":true,"description":"This is the create property basic description","allowed_values":["value1","value2"],"values_editable_by":"org_actors"}'

On the other hand, the API supports a default_value of null, but it seems like the SDK does not.

It uses *string for DefaultValue and I am not sure how to specify null (as opposed to "null"). I can live with using an empty string instead for my use case, but "" != null ...

I suspect the problem here is in the struct definition in orgs_properties.go:

// Default value of the property.
DefaultValue *string `json:"default_value,omitempty"`

It should (probably?) be without the omitempty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions