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

PutLifecycle invalid actions JSON #4186

Closed
lakario opened this issue Oct 31, 2019 · 1 comment
Closed

PutLifecycle invalid actions JSON #4186

lakario opened this issue Oct 31, 2019 · 1 comment
Assignees

Comments

@lakario
Copy link

lakario commented Oct 31, 2019

NEST/Elasticsearch.Net version: 7.4.0

Elasticsearch version: 7.4.x

Description of the problem including expected versus actual behavior:
The .NEST client does not create valid JSON for the actions of a PutLifecycle request. If more than one action is declared, there are no commas between the actions object members.

Steps to reproduce:

  1. Create 7.4.0 ElasticClient
  2. Call PutLifeycle with at least two actions for a single lifecycle phase
var client = new ElasticClient(new ConnectionSettings(new Uri("http://localhost:9200"))
		.DisableDirectStreaming());
	
var response = client.IndexLifecycleManagement.PutLifecycle(
	"policy1",
	pld => pld.Policy(pd => pd
		.Phases(phasesDesc => phasesDesc
			.Cold(phaseDesc => phaseDesc
				.Actions(actionsDesc => actionsDesc
					.Freeze(d => d)
					.SetPriority(d => d.Priority(50))
				)
			)
		)
	)
);

Provide ConnectionSettings (if relevant):
DisableDirectStreaming()

Provide DebugInformation (if relevant):

Invalid NEST response built from a unsuccessful (400) low level call on PUT: /_ilm/policy/policy1

Audit trail of this API call:

OriginalException: Elasticsearch.Net.ElasticsearchClientException: The remote server returned an error: (400) Bad Request.. Call: Status code 400 from: PUT /_ilm/policy/policy1. ServerError: Type: x_content_parse_exception Reason: "[1:51] [put_lifecycle_request] failed to parse field [policy]" CausedBy: "Type: x_content_parse_exception Reason: "[1:51] [lifecycle_policy] failed to parse field [phases]" CausedBy: "Type: x_content_parse_exception Reason: "[1:51] [phases] failed to parse field [cold]" CausedBy: "Type: x_content_parse_exception Reason: "[1:51] [phase] failed to parse field [actions]" CausedBy: "Type: json_parse_exception Reason: "Unexpected character ('"' (code 34)): was expecting comma to separate Object entries

at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@7750ef74; line: 1, column: 53]""""" ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at Elasticsearch.Net.HttpWebRequestConnection.Request[TResponse](RequestData requestData)
--- End of inner exception stack trace ---

Request:

{"policy":{"phases":{"cold":{"actions":{"freeze":{}"set_priority":{"priority":50}}}}}}

Response:

{"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:51] [phase] failed to parse field [actions]"}],"type":"x_content_parse_exception","reason":"[1:51] [put_lifecycle_request] failed to parse field [policy]","caused_by":{"type":"x_content_parse_exception","reason":"[1:51] [lifecycle_policy] failed to parse field [phases]","caused_by":{"type":"x_content_parse_exception","reason":"[1:51] [phases] failed to parse field [cold]","caused_by":{"type":"x_content_parse_exception","reason":"[1:51] [phase] failed to parse field [actions]","caused_by":{"type":"json_parse_exception","reason":"Unexpected character ('"' (code 34)): was expecting comma to separate Object entries\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@7750ef74; line: 1, column: 53]"}}}}},"status":400}

@codebrain codebrain self-assigned this Nov 12, 2019
@russcam
Copy link
Contributor

russcam commented Nov 12, 2019

count should be incremented after serializing a value:

russcam pushed a commit that referenced this issue Nov 13, 2019
This commit fixes a bug where the count was not incremented when serialising multiple lifecycle actions. 

Fixes #4186
russcam pushed a commit that referenced this issue Nov 13, 2019
This commit fixes a bug where the count was not incremented when serialising multiple lifecycle actions.

Fixes #4186

(cherry picked from commit b8318e6)
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

No branches or pull requests

3 participants