Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCIM] publish to masstransit fails #554

Closed
danflomin opened this issue Jul 24, 2023 · 10 comments
Closed

[SCIM] publish to masstransit fails #554

danflomin opened this issue Jul 24, 2023 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@danflomin
Copy link
Collaborator

Hello, how are you?

I'm having issues with publishing events related to data with nested groups.

I'm getting the following error when trying to publish the event.

A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.Message.Attribute.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.FlatAttributes.Representation.ExternalId.

Do you think you know what the root cause of this?
It was introduced when I upgraded from 2.0.25 to 4.0.2.

Kind regards
Dan

@simpleidserver simpleidserver self-assigned this Jul 24, 2023
@simpleidserver
Copy link
Owner

Hello :)

I believe you received this exception because the SCIMRepresentation object is being passed as a parameter to MassTransit, and it is not possible to serialize this object due to the presence of a reference to the Parent in the SCIMRepresentationAttribute attribute.

In the SCIM Server implementation, the SCIMRepresentation is not directly passed to MassTransit. Instead, it is serialized into JSON using the following code before being passed to MassTransit:

var content = newRepresentation.ToResponse(location, false);

Could you please check if you can serialize the Representation before passing the result to MassTransit?

KR,

SID

@danflomin
Copy link
Collaborator Author

Hello

I'm sorry for the incomplete information.

The exception was of type System.Runtime.Serialization.SerializationException

System.Runtime.Serialization.SerializationException: Failed to serialize message
  File "/_/src/MassTransit/Serialization/SystemTextJsonMessageBody.cs", line 56, col 17, in byte[] SystemTextJsonMessageBody<TMessage>.GetBytes()
  File "/_/src/MassTransit/InMemoryTransport/InMemoryTransport/InMemorySendTransportContext.cs", line 58, col 13, in Task InMemorySendTransportContext.Send<T>(PipeContext transportContext, SendContext<T> sendContext)
  ?, in async Task SendPipe<T>.Send(TContext context)

Kind regards
Dan

@simpleidserver
Copy link
Owner

Thank you for raising the exception, but it should not occur in the SCIM Server. This is because the SCIMRepresentation is directly passed to MassTransit, but before sending it to MassTransit, it is first serialized into JSON.

Have you added custom code that sends the SCIMRepresentation instead of the JSON object?

Please refer to my previous message for more information :)

@danflomin
Copy link
Collaborator Author

No I did not :(
I wonder if it happens due to a corruption in the data (maybe a circular memberships of groups?).

I guess that prior to publishing the event, it will be preferable to not add the representation that is attached to the attribute as well (it happens only for reference events).

WDYT?

@danflomin
Copy link
Collaborator Author

Also, can you please add my account as a contributor? I'd like to submit a pull request

@simpleidserver
Copy link
Owner

Oops, my bad !

The exception is being thrown because the SCIMRepresentationAttribute is passed as a parameter into the events RepresentationRefAttributeAddedEvent, RepresentationRefAttributeRemovedEvent, and RepresentationRefAttributeUpdatedEvent. Consequently, an infinite loop occurs between SCIMRepresentationAttribute and SCIMRepresentation.

I will ignore the Representation attached to the SCIMRepresentationAttribute :)

I have sent you an invitation to become a collaborator

@simpleidserver simpleidserver added the bug Something isn't working label Jul 25, 2023
thabart added a commit that referenced this issue Jul 25, 2023
@simpleidserver
Copy link
Owner

The issue should be fixed in the branch release/4.0.2

Changeset : 1419d76

@danflomin
Copy link
Collaborator Author

danflomin commented Jul 25, 2023 via email

@danflomin
Copy link
Collaborator Author

Hello

I pushed an improvement to release/4.0.2.
I need this for my application.

Is that OK?

Kind regards
Dan

@simpleidserver
Copy link
Owner

Hello,

Sorry for my late reply, i'm ok with your changes :)

KR,

SID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

2 participants