From 44546a3480bca47b76ff6d5744f234c773464099 Mon Sep 17 00:00:00 2001 From: mountford Date: Fri, 28 Apr 2017 11:44:03 -0700 Subject: [PATCH] Throw error in get_history_entries if the specified ID is invalid Currently, if the ID is invalid, parentKey is set to null, causing it to return all history entries. Note that there is still a problem that you cannot look up history entries for entities which have been soft deleted, because the foreign key lookup won't work. That is unfortunate, but at least this simple fix makes things better than they were. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154564262 --- java/google/registry/tools/GetHistoryEntriesCommand.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/google/registry/tools/GetHistoryEntriesCommand.java b/java/google/registry/tools/GetHistoryEntriesCommand.java index 470587e1c..f09b91b74 100644 --- a/java/google/registry/tools/GetHistoryEntriesCommand.java +++ b/java/google/registry/tools/GetHistoryEntriesCommand.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME; +import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import static org.joda.time.DateTimeZone.UTC; import com.beust.jcommander.Parameter; @@ -63,6 +64,7 @@ final class GetHistoryEntriesCommand implements RemoteApiCommand { type != null && uniqueId != null, "If either of 'type' or 'id' are set then both must be"); parentKey = type.getKey(uniqueId, DateTime.now(UTC)); + checkArgumentNotNull(parentKey, "Invalid resource ID"); } for (HistoryEntry entry : (parentKey == null