I have a SpringBoot application. On one of the POST endpoints, in the body I want a field that can contain emoji.
In my request object I have the following field:
private final String name;
In the body of my request I have the following input:
"name" : "Hello, playground \Ud83d\Ude0a \Ud83e\Udd21\Ud83d\Udc68\U200d\Ud83c\Udf73 \U2663\Ufe0f"
which contains some emojis.
The exception I get is:
com.fasterxml.jackson.databind.JsonMappingException: Unrecognized character escape 'U' (code 85)
and
Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized character escape 'U' (code 85)
I tried to set the following flag on my object mapper with no luck:
.configure(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true)
Any ideas?
Related
I am having the below error while deploying Jupiterhub
Spawn failed: (422) Reason: error HTTP response headers:
,"status":"Failure","message":"PersistentVolumeClaim "" is invalid: [metadata.name: Required value: name or generateName is required, metadata.labels: Invalid value: "-42hattacharjee-5f-5f-41nusuya": a valid label must be an empty string or consist of alphanumeric characters, '-', '' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9.]*)?[A-Za-z0-9])?')]",
I have tried removing the username from the "pvcNameTemplate" parameter but still getting this error.
I'm having these json parsing errors from time to time:
2022-01-07T12:15:19,872][WARN ][logstash.filters.json ] Error parsing json
{:source=>"message", :raw=>" { the invalid json }", :exception=>#<LogStash::Json::ParserError: Unrecognized character escape 'x' (code 120)
Is there a way to get the :exception field in the logstash config file?
I opened the exact same thread on the elastic forum and got a working solution there. Thanks to #Badger on the forum, I ended up using the following raw ruby filter:
ruby {
code => '
#source = "message"
source = event.get(#source)
return unless source
begin
parsed = LogStash::Json.load(source)
rescue => e
event.set("jsonException", e.to_s)
return
end
#target = "jsonData"
if #target
event.set(#target, parsed)
end
'
}
which extracts the info I needed:
"jsonException" => "Unexpected character (',' (code 44)): was expecting a colon to separate field name and value\n at [Source: (byte[])\"{ \"baz\", \"oh!\" }\r\"; line: 1, column: 9]",
Or as the author of the solution suggested, get rid of the #target part and use the normal json filter for the rest of the data.
Following is the exception stackify shows me on dashboard:
ERROR The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.
System.FormatException: The string was not recognized as a valid DateTime. There is an unknown word starting at index 0. ---> System.FormatException: null is not a valid value for DateTime.
at System.DateTimeParse.Parse
at System.ComponentModel.DateTimeConverter.ConvertFrom
--- End of inner exception stack trace ---
at System.ComponentModel.DateTimeConverter.ConvertFrom
at System.ComponentModel.NullableConverter.ConvertFrom
at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.SimpleTypeModelBinder.BindModelAsync
I am not able to understand which field of the viewmodel causes the issue like this. How can I catch this exception on my local code?
I am trying to parse error logs using Logstash to capture few fields especially errormessage. But unable to capture errormessage in Logstash. Below is the actual error message and parser which I wrote
12345 http://google.com 2017-04-17 09:02:43.065 ERROR 10479 --- [http-nio-8052-exec-2] com.utilities.TokenUtils : Error
org.xml.SAXParseException: An invalid XML character (Unicode: 0xe) was found in the value of attribute "ID" and element is "saml".
at org.apache.parsers.DOMParser.parse(Unknown Source)
at org.apache.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
at com.utilities.TokenUtils.validateSignature(TokenUtils.java:99)
Parser:
`%{NOTSPACE:stnum}\s*%{NOTSPACE:requestURL}\s*%{TIMESTAMP_ISO8601:log_timestamp}\s*%{LOGLEVEL:loglevel}\s*%{NUMBER:pid}\s*---\s*\[(?<thread>[A-Za-z0-9-]+)\]\s*%{DATA:class}\s*:\s%{NOTSPACE:level}\s*(?<errormessage>.[^\n]*).[^\n]*`
I am trying to capture this message from the log:
org.xml.SAXParseException: An invalid XML character (Unicode: 0xe) was found in the value of attribute "ID" and element is "saml".
Which logstash parser you are using? Please provide while conf file which can give us more info. Here's the sample to parse exception type from your logs (Using grok filter).
filter {
grok {
match => ["message", "%{DATA:errormessage} %{GREEDYDATA:EXTRA}"]
}
}
I am using OAuth2 with Spring Security.
My authentication manager configures client via database: clients.jdbc(dataSource());
Everything works, but when requesting a token, I get an exception:
2017-04-28 11:14:39.656 WARN 1200 --- [io-8096-exec-10] o.s.s.o.p.c.JdbcClientDetailsService : Could not decode JSON for additional information: BaseClientDetails [clientId=myclientid, clientSecret=mysecret, scope=[myscope], resourceIds=[], authorizedGrantTypes=[authorization_code, refresh_token], registeredRedirectUris=null, authorities=[], accessTokenValiditySeconds=36000, refreshTokenValiditySeconds=36000, additionalInformation={}]
with trace:
org.codehaus.jackson.JsonParseException: Unexpected character ('a' (code 97)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: java.io.StringReader#557a138f; line: 1, column: 2]
...
...
where the column additional_information (varchar(4096)) in table client_details is "asdf" for this entry.
I also tried to change the type of additional_information from String to Map<String, Object> and inserting a string by putting and getting it into the map with the key 'info'. After this, I get the same error, with different trace:
org.codehaus.jackson.JsonParseException: Unrecognized token 'asdf': was expecting at [Source: java.io.StringReader#3e8a7a77; line: 1, column: 21]
...
...
How can I include additional_information into my token?