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

regenerate activity URL when importing Workflows #15291

Merged
merged 8 commits into from
Feb 10, 2024

Conversation

lampersky
Copy link
Contributor

fixes #15087

@hishamco
Copy link
Member

hishamco commented Feb 9, 2024

Why the build fail in Ubuntu?

@lampersky
Copy link
Contributor Author

Why the build fail in Ubuntu?

no idea @hishamco , can you rerun the build?

@hishamco
Copy link
Member

hishamco commented Feb 9, 2024

Sure I will re-run this again

@sebastienros
Copy link
Member

Already did, failed again.

@sebastienros
Copy link
Member

CORS issue (check the messages). Maybe some node version problem in the scripts, there are warnings in the build.

@hishamco
Copy link
Member

hishamco commented Feb 9, 2024

The issue related to the JSON conversion, @lampersky please check the logs

https://github.com/OrchardCMS/OrchardCore/actions/runs/7843466469/job/21417779248?pr=15291

@sebastienros
Copy link
Member

I had not thought about this, these functional test recipes are only run on Linux, and the coming soon one imports a workflow for the subscription form. So it makes sense now. Here is the error message:

      System.Text.Json.JsonException: The JSON value could not be converted to System.Int32. Path: $ | LineNumber: 0 | BytePositionInLine: 4.
       ---> System.InvalidOperationException: Cannot get the value of a token type 'Null' as a number.
         at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedNumber(JsonTokenType tokenType)
         at System.Text.Json.Utf8JsonReader.TryGetInt32(Int32& value)
         at System.Text.Json.Serialization.Converters.Int32Converter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
         at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
         at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
         --- End of inner exception stack trace ---
         at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
         at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
         at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
         at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
         at System.Text.Json.JsonSerializer.ReadFromNode[TValue](JsonNode node, JsonTypeInfo`1 jsonTypeInfo)
         at System.Text.Json.JsonSerializer.Deserialize[TValue](JsonNode node, JsonSerializerOptions options)
         at System.Text.Json.Nodes.JNode.ToObject[T](JsonNode jsonNode, JsonSerializerOptions options) in /_/src/OrchardCore/OrchardCore.Abstractions/Json/Nodes/JNode.cs:line 100
         at OrchardCore.Workflows.Recipes.WorkflowTypeStep.ReGenerateHttpRequestEventUrl(WorkflowType workflow, ActivityRecord activity) in /_/src/OrchardCore.Modules/OrchardCore.Workflows/Recipes/WorkflowTypeStep.cs:line 66
         at OrchardCore.Workflows.Recipes.WorkflowTypeStep.ExecuteAsync(RecipeExecutionContext context) in /_/src/OrchardCore.Modules/OrchardCore.Workflows/Recipes/WorkflowTypeStep.cs:line 46


private string ReGenerateHttpRequestEventUrl(WorkflowType workflow, ActivityRecord activity)
{
var tokenLifeSpan = activity.Properties["TokenLifeSpan"]?.ToObject<int>() ?? 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it actually try to generate the token property if there is no or invalid tokenlifespan?

Copy link
Member

@sebastienros sebastienros Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For instance if a request has no token, this code here would generate a 0-lifespan one so the request would fail, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, it's better to go with infinite token lifespan than no working activity at all. But it is up to you. What is your preference here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

than no working activity at all

I don't understand, maybe I am missing some info. I thought that you could have request workflow that are not protected by a token. Is that correct? In that case you would still generate a token even if it's not necessary with your first suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that you could have request workflow that are not protected by a token. Is that correct?

no, every request to any HttpRequestEvent is protected by a token, a token is just an ecrypted json (it contains workflowId and ActivityId), this token has some lifespan, even if it isn't provided we are using some predefined value (100 years = ~36500 days)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't remember the details.

@lampersky
Copy link
Contributor Author

@sebastienros To maintain backward compatibility, I will treat activities without a provided timespan as never expiring.
Here it is part of comingsoon.recipe.json:

image

@sebastienros
Copy link
Member

@lampersky good. However might still be better to not add a token if there were none before, assuming that's something that can happen. Shouldn't be hard in code either, just a condition before generating the link instead of defaulting to infinite lifetime.

@lampersky
Copy link
Contributor Author

@sebastienros I've just pushed suggested changes. The activity URL is only refreshed when token life time is provided.
Now windows build is failing :-D

image

@hishamco hishamco merged commit bedf9f8 into OrchardCMS:main Feb 10, 2024
4 checks passed
@lampersky lampersky deleted the lampersky/fix15087 branch February 10, 2024 23:47
urbanit pushed a commit to urbanit/OrchardCore that referenced this pull request Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP Request workflow event is not triggered if imported
3 participants