Merge "Trim the invalid uids and tags when reading uids/tags from chain." into pi-dev