Skip to content

Method UpdateSCIMGroupAttribute() fails with Bad request (400) when adding/removing members #3968

@elminster-aom

Description

@elminster-aom

I fear there's a bug with the type of Value in:

type SCIMEnterpriseAttributeOperation struct {
	Op    string  `json:"op"`              // Can be one of: `add`, `replace`, `remove`.
	Path  *string `json:"path,omitempty"`  // Path to the attribute being modified (Filters are not supported).
	Value *string `json:"value,omitempty"` // New value for the attribute being modified.
}

For example, this code fails with a Bad request:

...
	addingMembers := github.SCIMEnterpriseAttribute{
		Operations: []*github.SCIMEnterpriseAttributeOperation{{
			Op:    "add",
			Path:  github.Ptr("members"),
			Value: github.Ptr(`[{"value":"1234abcd-1234-abcd-0004-123456789abcd"}]`),
		}},
		Schemas: []string{github.SCIMSchemasURINamespacesPatchOp},
	}
	group, resp, err := gh.Enterprise.UpdateSCIMGroupAttribute(ctx, "myenterprise", gId, addingMembers)
	if err != nil {
		attributeJson, _ := json.Marshal(addingMembers)
		return nil, fmt.Errorf("attribute:%v failed with %v: %w", string(attributeJson), resp.Status, err)
	}
...

OUTPUT:

level=ERROR msg="Update failed" err="attribute:{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":[{\"op\":\"add\",\"path\":\"members\",\"value\":\"[{\\\"value\\\":\\\"1234abcd-1234-abcd-0004-123456789abcd\\\"}]\"}]} failed: 400 Bad Request: PATCH https://api.github.com/scim/v2/enterprises/myenterprise/Groups/1235abcd-1234-abcd-0004-123456789abcd5: 400  []"
exit status 1

The final JSON looks malformed, too many scaped quotes (\").

ℹ️ I'd like to work in the solution

Metadata

Metadata

Assignees

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