Skip to content

[Apple] Guess string encoding when creating an NSString with UTF8 fails#1891

Merged
goaway merged 2 commits intoenvoyproxy:mainfrom
jpsim:nsstring-guess-encoding
Oct 21, 2021
Merged

[Apple] Guess string encoding when creating an NSString with UTF8 fails#1891
goaway merged 2 commits intoenvoyproxy:mainfrom
jpsim:nsstring-guess-encoding

Conversation

@jpsim
Copy link
Copy Markdown
Contributor

@jpsim jpsim commented Oct 21, 2021

  • Description: We're seeing issues in the wild where some headers are being dropped because the envoy_data values convert to a nil NSString value. It's possible these headers aren't encoded in valid UTF-8. So in the case where the string conversion fails, we can attempt to have NSString guess an encoding. I've added a log with some debugging breadcrumbs in the case where a string could be created with a fallback encoding, and in the case where that fallback fails as well.
  • Risk Level: Low. I suspect that most string conversions succeed, so the fallback path should be rarely hit.
  • Testing: Existing header tests and ran the Hello World sample apps and confirmed that header conversion work as expected.
  • Fixes: header handling: header value is nil in Obj-c #1825 (possibly)

And log when an NSString could not be created to help debug occurrences
in production.

Signed-off-by: JP Simard <[email protected]>
@jpsim jpsim marked this pull request as ready for review October 21, 2021 15:12
@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Oct 21, 2021

Could a maintainer please retry the failed CI workflows? They failed due to this GitHub incident which is now resolved.

@buildbreaker @goaway

Signed-off-by: JP Simard <[email protected]>
Copy link
Copy Markdown
Contributor

@goaway goaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be interesting to see what these logs show. Thanks @jpsim!

@goaway goaway merged commit 58d994f into envoyproxy:main Oct 21, 2021
@jpsim jpsim deleted the nsstring-guess-encoding branch October 21, 2021 18:37
jpsim added a commit to jpsim/envoy-mobile that referenced this pull request Oct 21, 2021
* origin/main:
  [Apple] Guess string encoding when creating an NSString with UTF8 fails (envoyproxy#1891)
  Link android dev document in a doctree (envoyproxy#1892)
  bazel: Remove rules_jvm_external dep on JAVA_HOME (envoyproxy#1890)
  release: 0.4.3.20211020 (envoyproxy#1887)
  Add debug instructions and sample bazelproject (envoyproxy#1888)
  bazel: Use hermetic JDK 11 (envoyproxy#1863)
  envoy: bump upstream to c687308 (envoyproxy#1886)
  docs: how to test with local envoy (envoyproxy#1876)
  network: implement initial heuristic for binding alternate interface (envoyproxy#1858)
  Assign an int to each log level (envoyproxy#1885)
  envoy: bump upstream to a5b3af2 (envoyproxy#1884)
  android: stub out jni logging by default (envoyproxy#1879)
  CI: Add local JDK to asan/tsan builds (envoyproxy#1878)
  Make JniBridgeUtility public (envoyproxy#1880)
  swift: Fix Swift version in podspec (envoyproxy#1875)

Signed-off-by: JP Simard <[email protected]>
@Augustyniak
Copy link
Copy Markdown
Contributor

I think that the approach in this PR may work but I'm worried that we will never be able to tell whether it fixed the issue or not.

How/Where are we going to see added logs?

@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Oct 22, 2021

How/Where are we going to see added logs?

I believe we'd only be able to capture this locally for now. We'll need to come up with a mechanism to emit logger events from within a C header context. That's why I left the ENVOY_LOG_EVENT todo in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants