-
Notifications
You must be signed in to change notification settings - Fork 459
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
Error flatmap_filter - move value in array #955
Comments
Before digging deeper, I've noticed your expected behavior is not correct, can you please double check what are you actually expecting to see? On the other hand, have you checked that your transformation is valid according to the documentation? https://www.krakend.io/docs/backends/flatmap/#notation-by-example |
Hi, so, the expected behave is the same as this command: {
"type": "move",
"args": ["schools.*.title", "schools.*.name"]
}, Sure, I'm trying to move to another structure, but I don`t understand why the actual result is according with the described in the result section and not according with the Expected behavior section. |
Hi, so what you're expecting to see is this output right?
|
In any case, and, in order to check if this is indeed a bug and needs some fixing, could you please modify this config file to reproduce your case?
|
Input[{
"A": {
"B": [
{
"C": [
{
"D": [
{
"E": [
{
"F": 22
}
]
}
]
},
{
"D": [
{
"E": [
{
"F": 33
}
]
}
]
},
{
"D": [
{
"E": [
{
"F": 44
}
]
}
]
}
]
}
]
}
}] Output[{
"A": {
"B": [
{
"C": [
{
"D": [
{
"G": 22
}
]
},
{
"D": [
{
"G": 33
}
]
},
{
"D": [
{
"G": 44
}
]
}
]
}
]
}
}] "flatmap_filter": {
{
"type": "move",
"args": [
"collection.*.A.B.*.C.*.D.*.E.*.F",
"collection.*.A.B.*.C.*.D.*.G"
]
}
} |
{
"$schema": "https://www.krakend.io/schema/v2.8/krakend.json",
"version": 3,
"endpoints": [
{
"endpoint": "/v1/version/pudate",
"method": "POST",
"output_encoding": "json-collection",
"input_headers": [
"X-Key",
"X-ID",
"User-Agent"
],
"backend": [
{
"url_pattern": "/version/update",
"host": [
"{{ .env.services.host }}"
],
"is_collection": true,
"extra_config": {
"backend/http": {
"return_error_code": true
},
"flatmap_filter": {
{
"type": "move",
"args": [
"collection.*.A.B.*.C.*.D.*.E.*.F",
"collection.*.A.B.*.C.*.D.*.G"
]
}
}
},
"method": "POST"
}
]
}
]
} |
I cannot reproduce your problem with that config, in fact, that config does not work at all, there are some problems:
It'd be really helpful if you could provide a valid configuration aligned with the expected response of Thanks |
|
I'm still not able to reproduce:
Please check your config file and provide a proper one so we can check the issue, thanks |
First of all, thank you very much for your attention.
{
"@comment": "This file was auto generated from 'krakend.tmpl' file",
"$schema": "https://www.krakend.io/schema/v2.5/krakend.json",
"name": "platform-api",
"version": 3,
"host": [
"http://api:8000"
],
"timeout": "60s",
"cache_ttl": "300s",
"extra_config": {
"router": {
"return_error_msg": true,
"auto_options": true
},
"telemetry/opentelemetry": {
"service_name": "ABC_API",
"service_version": "1",
"metric_reporting_period": 1,
"trace_sample_rate": 0.15,
"exporters": {
"otlp": [
{
"name": "apm",
"host": "apm.elastic.svc.cluster.local",
"port": 8200,
"use_http": false
}
]
},
"layers": {
"global": {
"disable_metrics": false,
"disable_traces": false,
"disable_propagation": false
},
"proxy": {
"disable_metrics": false,
"disable_traces": false
},
"backend": {
"metrics": {
"disable_stage": false,
"round_trip": true,
"read_payload": true,
"detailed_connection": true
},
"traces": {
"disable_stage": false,
"round_trip": true,
"read_payload": true,
"detailed_connection": true
}
}
}
},
"security/cors": {
"allow_origins": [
"https://developer.com.br"
],
"allow_methods": [
"GET",
"HEAD",
"POST",
"PATCH"
],
"expose_headers": [
"Content-Length",
"Content-Type"
],
"allow_headers": [
"Accept-Language"
],
"max_age": "12h",
"allow_credentials": false,
"debug": true
},
"auth/validator": {
"shared_cache_duration": 3600
},
"telemetry/logging": {
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
}
},
"plugin": {
"pattern": ".so",
"folder": "./plugins/"
},
"endpoints": [
{
"endpoint": "/flows",
"method": "POST",
"output_encoding": "json-collection",
"input_headers": [
"My-Key",
"My-ID",
"User-Agent"
],
"backend": [
{
"url_pattern": "/flow",
"host": [
"http://host.docker.internal:8000"
],
"is_collection": true,
"extra_config": {
"backend/http": {
"return_error_code": true
},
"proxy": {
"flatmap_filter": [
{
"type": "move",
"args": [
"collection.*.A.B.*.C.*.D.*.E.*.F",
"collection.*.A.B.*.C.*.D.*.G"
]
}
]
}
},
"method": "POST"
}
]
}
]
} |
I was able to reproduce, and I'm afraid you cannot accomplish what you want with the My recommendation here would be to use the |
Environment info:
Running with DockerFile
Describe the bug
When applying :
To the Payload:
The result is:
Your configuration file:
We use krakend.tmpl
"$schema": "https://www.krakend.io/schema/v2.5/krakend.json",
Commands used
How did you start the software?
Expected behavior
The return should be:
The text was updated successfully, but these errors were encountered: