Remove document text from error message in a couple of ops (#9003)

This commit is contained in:
Hariharan Seshadri 2021-09-11 08:37:52 -07:00 committed by GitHub
parent c3321b1778
commit c674343d94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -128,8 +128,10 @@ Status Tokenizer::CharTokenize(OpKernelContext* ctx, size_t N, size_t C,
size_t tokens = 0; // length in utf8 chars
if (!utf8_validate(reinterpret_cast<const unsigned char*>(s.data()), s.size(),
tokens)) {
// Please do not include the input text in the error message as it could
// be deemed as a compliance violation by teams using this operator
return Status(common::ONNXRUNTIME, common::INVALID_ARGUMENT,
"Input string contains invalid utf8 chars: " + s);
"Input string contains invalid utf8 chars");
}
max_tokens = std::max(max_tokens, tokens);
++curr_input;

View file

@ -224,8 +224,10 @@ Status CopyCaseAction(ForwardIter first, ForwardIter end, OpKernelContext* ctx,
if (caseaction == StringNormalizer::LOWER || caseaction == StringNormalizer::UPPER) {
std::wstring wstr = converter.from_bytes(s);
if (wstr == wconv_error) {
// Please do not include the input text in the error message as it could
// be deemed as a compliance violation by teams using this operator
return Status(common::ONNXRUNTIME, common::INVALID_ARGUMENT,
"Input contains invalid utf8 chars at: " + static_cast<const std::string&>(s));
"Input contains invalid utf8 chars");
}
// In place transform
loc.ChangeCase(caseaction, wstr);
@ -357,8 +359,10 @@ Status StringNormalizer::Compute(OpKernelContext* ctx) const {
const std::string& s = *first;
std::wstring wstr = converter.from_bytes(s);
if (wstr == wconv_error) {
// Please do not include the input text in the error message as it could
// be deemed as a compliance violation by teams using this operator
return Status(common::ONNXRUNTIME, common::INVALID_ARGUMENT,
"Input contains invalid utf8 chars at: " + s);
"Input contains invalid utf8 chars");
}
locale.ChangeCase(compare_caseaction_, wstr);
if (0 == wstopwords_.count(wstr)) {