mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Add EPP controller logging for XML unmarshalling failures
This will make it much easier to detect issues with bad EPP XML (e.g. the one in the loadtest action fixed in [] based on the request logs, since otherwise the only indication of what went wrong is the EPP response returned to the client, which we don't store anywhere. Now we'll get log messages that look like this: google.registry.flows.EppController handleEppCommand: EPP request XML unmarshalling failed - "Syntax error at line 2, column 7: cvc-elt.1: Cannot find the declaration of element 'epp'.": (EppController.java:59) {"clientId":"CharlestonRoad","resultCode":2001,"resultMessage":"Command syntax error","xmlBytes":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI\/Pgo8ZXBwLz4K"} ======================================== <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <epp/> ======================================== google.registry.flows.EppXmlTransformer$GenericSyntaxErrorException: Syntax error at line 2, column 7: cvc-elt.1: Cannot find the declaration of element 'epp'. at google.registry.flows.EppXmlTransformer.unmarshal(EppXmlTransformer.java:89) at google.registry.flows.EppController.handleEppCommand(EppController.java:56) at google.registry.flows.EppRequestHandler.executeEpp(EppRequestHandler.java:37) at google.registry.flows.EppToolAction.run(EppToolAction.java:33) <snip> ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137363446
This commit is contained in:
parent
21c0b43af0
commit
bc0116f3a0
1 changed files with 24 additions and 4 deletions
|
@ -14,11 +14,16 @@
|
|||
|
||||
package google.registry.flows;
|
||||
|
||||
import static com.google.common.base.Strings.nullToEmpty;
|
||||
import static com.google.common.io.BaseEncoding.base64;
|
||||
import static google.registry.flows.EppXmlTransformer.unmarshal;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.flows.FlowModule.EppExceptionInProviderException;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
|
@ -30,6 +35,7 @@ import google.registry.monitoring.whitebox.BigQueryMetricsEnqueuer;
|
|||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import javax.inject.Inject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
/**
|
||||
* An implementation of the EPP command/response protocol.
|
||||
|
@ -46,7 +52,7 @@ public final class EppController {
|
|||
@Inject BigQueryMetricsEnqueuer bigQueryMetricsEnqueuer;
|
||||
@Inject EppController() {}
|
||||
|
||||
/** Read EPP XML, execute the matching flow, and return an {@link EppOutput}. */
|
||||
/** Reads EPP XML, executes the matching flow, and returns an {@link EppOutput}. */
|
||||
public EppOutput handleEppCommand(
|
||||
SessionMetadata sessionMetadata,
|
||||
TransportCredentials credentials,
|
||||
|
@ -61,7 +67,21 @@ public final class EppController {
|
|||
try {
|
||||
eppInput = unmarshal(EppInput.class, inputXmlBytes);
|
||||
} catch (EppException e) {
|
||||
// Send the client an error message, with no clTRID since we couldn't unmarshal it.
|
||||
// Log the unmarshalling error, with the raw bytes (in base64) to help with debugging.
|
||||
logger.infofmt(
|
||||
e,
|
||||
"EPP request XML unmarshalling failed - \"%s\":\n%s\n%s\n%s\n%s",
|
||||
e.getMessage(),
|
||||
JSONValue.toJSONString(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"clientId", nullToEmpty(sessionMetadata.getClientId()),
|
||||
"resultCode", e.getResult().getCode().code,
|
||||
"resultMessage", e.getResult().getCode().msg,
|
||||
"xmlBytes", base64().encode(inputXmlBytes))),
|
||||
Strings.repeat("=", 40),
|
||||
new String(inputXmlBytes, UTF_8).trim(), // Charset decoding failures are swallowed.
|
||||
Strings.repeat("=", 40));
|
||||
// Return early by sending an error message, with no clTRID since we couldn't unmarshal it.
|
||||
metricBuilder.setStatus(e.getResult().getCode());
|
||||
return getErrorResponse(e.getResult(), Trid.create(null));
|
||||
}
|
||||
|
@ -92,7 +112,7 @@ public final class EppController {
|
|||
}
|
||||
}
|
||||
|
||||
/** Run an EPP flow and convert known exceptions into EPP error responses. */
|
||||
/** Runs an EPP flow and converts known exceptions into EPP error responses. */
|
||||
private EppOutput runFlowConvertEppErrors(FlowComponent flowComponent) {
|
||||
try {
|
||||
return flowComponent.flowRunner().run();
|
||||
|
@ -107,7 +127,7 @@ public final class EppController {
|
|||
}
|
||||
}
|
||||
|
||||
/** Create a response indicating an EPP failure. */
|
||||
/** Creates a response indicating an EPP failure. */
|
||||
@VisibleForTesting
|
||||
static EppOutput getErrorResponse(Result result, Trid trid) {
|
||||
return EppOutput.create(new EppResponse.Builder()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue