[SOLVED] Rule: "Populate index in ElasticSearch" throws exception during execution


#1

I’m submitting a…

[ ] Regression (a behavior that topped working in a new release)
[x ] Bug report
[ ] Performance issue
[ ] Documentation issue or request

Current behavior

I have an Elastic rule. This is the configuration I found in MongoDB:

{ 
    "_id" : "1eece304-c19b-4b9d-961f-7288f4aff1d1", 
    "Version" : NumberLong(4), 
    "Doc" : {
        "appId" : "ddd705bd-3cf0-4f6e-ba88-71300130fa6b,identity", 
        "ruleDef" : {
            "trigger" : {
                "§type" : "ContentChangedTrigger", 
                "schemas" : [

                ], 
                "handleAll" : true, 
                "isFrozen" : true
            }, 
            "action" : {
                "§type" : "ElasticSearchAction", 
                "host" : "http://localhost:9200/", 
                "indexName" : "squidex", 
                "indexType" : "$SCHEMA_NAME", 
                "isFrozen" : true
            }, 
            "isEnabled" : true
        }, 
        "isDeleted" : true, 
        "id" : "1eece304-c19b-4b9d-961f-7288f4aff1d1", 
        "createdBy" : "subject:5b9256f0c45e9700010b8767", 
        "lastModifiedBy" : "subject:5b9256f0c45e9700010b8767", 
        "created" : "2018-09-07T12:28:01Z", 
        "lastModified" : "2018-09-07T12:32:01Z", 
        "version" : NumberLong(4)
    }
}

When I trigger the rule, I get the following exception:

System.ArgumentNullException: Value cannot be null.
Parameter name: uriString
   at System.Uri..ctor(String uriString, UriKind uriKind)
   at Squidex.Domain.Apps.Core.HandleRules.Actions.ElasticSearchActionHandler.ExecuteJobAsync(ElasticSearchJob job) in /src/Squidex.Domain.Apps.Core.Operations/HandleRules/Actions/ElasticSearchActionHandler.cs:line 99
   at Squidex.Domain.Apps.Core.HandleRules.RuleActionHandler`2.Squidex.Domain.Apps.Core.HandleRules.IRuleActionHandler.ExecuteJobAsync(JObject data) in /src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionHandler.cs:line 36
   at Squidex.Domain.Apps.Core.HandleRules.RuleService.InvokeAsync(String actionName, JObject job) in /src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs:line 126

The concrete RuleEvent found in MongoDB:

{ 
    "_id" : "5fcbbb55-42f6-452d-af79-3ff7cfdd24d2", 
    "Created" : ISODate("2018-09-07T12:28:34.808+0000"), 
    "LastModified" : ISODate("1970-01-01T00:00:00.000+0000"), 
    "AppId" : "ddd705bd-3cf0-4f6e-ba88-71300130fa6b", 
    "Result" : "Failed", 
    "JobResult" : "Retry", 
    "Job" : {
        "jobId" : "5fcbbb55-42f6-452d-af79-3ff7cfdd24d2", 
        "appId" : "ddd705bd-3cf0-4f6e-ba88-71300130fa6b", 
        "aggregateId" : "62ffd8e6-05e3-407b-ab34-41955bcd6a19", 
        "eventName" : "ApiResourcesUnpublished", 
        "actionName" : "ElasticSearchAction", 
        "description" : "Ignore", 
        "created" : "2018-09-07T12:28:34Z", 
        "expires" : "2018-09-09T12:28:34Z", 
        "actionData" : {
            "Host" : null, 
            "Username" : null, 
            "Password" : null, 
            "ContentId" : null, 
            "IndexName" : null, 
            "IndexType" : null, 
            "Content" : null
        }
    }, 
    "LastDump" : "System.ArgumentNullException: Value cannot be null.\nParameter name: uriString\n   at System.Uri..ctor(String uriString, UriKind uriKind)\n   at Squidex.Domain.Apps.Core.HandleRules.Actions.ElasticSearchActionHandler.ExecuteJobAsync(ElasticSearchJob job) in /src/Squidex.Domain.Apps.Core.Operations/HandleRules/Actions/ElasticSearchActionHandler.cs:line 99\n   at Squidex.Domain.Apps.Core.HandleRules.RuleActionHandler`2.Squidex.Domain.Apps.Core.HandleRules.IRuleActionHandler.ExecuteJobAsync(JObject data) in /src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionHandler.cs:line 36\n   at Squidex.Domain.Apps.Core.HandleRules.RuleService.InvokeAsync(String actionName, JObject job) in /src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs:line 126", 
    "NumCalls" : NumberInt(3), 
    "Expires" : ISODate("2018-09-09T12:28:34.000+0000"), 
    "NextAttempt" : ISODate("2018-09-07T18:28:34.000+0000")
}

You can see that the Rule itself contains parameter values, but during event creation, all event parameters are lost.

Expected behavior

A request to elastic is made.

Minimal reproduction of the problem

I think the problem is in ElasticSearchActionHandler.CreateJob.

There is a check on EnrichedContentEvent which creates an ElasticSearchJob and populates its data, but the job is never returned. In any case a new empty ElasticSearchJob instance is returned.

There should be:

a) return created job, e.g.

    return (ruleDescription, ruleJob);
}

return (DescriptionIgnore, new ElasticSearchJob());

b) Respect the jobs which contains the job description “Ignore” (assigned via constant) and don’t execute them (in case this is the intention of the constant DescriptionIgnore.)

Environment

  • [x ] Self hosted with version docker v1.10
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Browser:

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:


#2

Hi,
thanks for your bug report. I see two problems:

  1. There is a check missing in the Execute method as you said.
  2. The ApiResourcesUnpublished should be an EnrichedContentEvent.

Forget what i said, your bugfix is correct.


#3

I commited the potential bugfix. Can you test it? I have no ElasticSearch installed right now.


#4

It works. Can be closed successfully. Thanks!


#5