-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Report parser name and location in XContent deprecation warnings #53752
Report parser name and location in XContent deprecation warnings #53752
Conversation
Pinging @elastic/es-core-infra (:Core/Infra/Core) |
I also changed the 'this field has been removed entirely' message to read more easily. |
if (parserName != null) { | ||
deprecationLogger.deprecated("[{}][{}] Deprecated field [{}] used, expected [{}] instead", | ||
parserName, location.get(), usedName, modernName); | ||
} else { | ||
deprecationLogger.deprecated("Deprecated field [{}] used, expected [{}] instead", usedName, modernName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only suggestion I'd make is about whether it's possible to consolidate the log messages. For example:
if (parserName != null) { | |
deprecationLogger.deprecated("[{}][{}] Deprecated field [{}] used, expected [{}] instead", | |
parserName, location.get(), usedName, modernName); | |
} else { | |
deprecationLogger.deprecated("Deprecated field [{}] used, expected [{}] instead", usedName, modernName); | |
} | |
String prefix = parserName == null ? "" : | |
"[" + parserName + "][" + location.get() + "] "; | |
deprecationLogger.deprecated("{}Deprecated field [{}] used, expected [{}] instead", prefix, usedName, modernName); |
deprecationLogger.deprecated("[{}][{}] Deprecated field [{}] used, this field is unused and will be removed entirely", | ||
parserName, location.get(), usedName); | ||
String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; | ||
if (true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, out-of-date diff 😅
Thanks for the review @pugnascotia ! |
It's simple to deprecate a field used in an
ObjectParser
just by adding deprecationmarkers to the relevant
ParseField
objects. The warnings themselves don't currentlyhave any context - they simply say that a deprecated field has been used, but not
where in the input xcontent it appears. This commit adds the parent object parser
name and
XContentLocation
to these deprecation messages.