Repository navigation
Fix cloud login: decode JWT payload with matlab.net.base64decode - #1024
Conversation
ndi.cloud.internal.decodeJwt used javax.xml.bind.DatatypeConverter to Base64-decode the JWT payload. That class is not in the Java shipped with recent MATLAB releases, so ndi.cloud.authenticate failed in getTokenExpiration with MATLAB:undefinedVarOrClass and every cloud test that logs in errored. Use MATLAB's built-in matlab.net.base64decode. Add ndi.unittest.cloud.DecodeJwtTest, an offline test that builds JWTs locally and covers 0, 1 and 2 stripped padding characters and a UTF-8 payload. Not run locally (no MATLAB in this environment); CI validates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H3DDr2ybuwd2XoVfBEsU38
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1024 +/- ##
==========================================
- Coverage 30.20% 30.17% -0.04%
==========================================
Files 866 870 +4
Lines 44014 44076 +62
==========================================
+ Hits 13296 13298 +2
- Misses 30718 30778 +60 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
No fix is needed in this PR. The check may update when the Cloud CI 1/3 jobs upload coverage. I can't re-run a Codecov status from here. Generated by Claude Code |
Brings in the ndi.cloud.api.feedback commands + feedbackTest (#1023) and the cloud login JWT decode fix (#1024). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016wj6cuvAwgAaYN5dNM1o6L
Root cause
ndi.cloud.internal.decodeJwtdecoded the JWT payload withjavax.xml.bind.DatatypeConverter.parseBase64Binary. The Java shipped with the MATLAB used in CI (setup-matlab,release: latest) no longer includesjavax.xml.bind, so the call fails withMATLAB:undefinedVarOrClass("Unable to resolve the name 'javax.xml.bind.DatatypeConverter.parseBase64Binary'").The call chain is
ndi.cloud.authenticate→isAuthenticated→ndi.cloud.internal.getActiveToken→getTokenExpiration→decodeJwt. Every cloud test that logs in therefore errors before it sends a request.Evidence:
mainhas failed daily since at least 2026-10-04. In run 38099712583 the dev job hits this error 68 times, with 107 tests failed.Changes
src/ndi/+ndi/+cloud/+internal/decodeJwt.m: a one-line change tomatlab.net.base64decode(payloadBase64). The lines above it already turn Base64Url into padded standard Base64. The decoder returns auint8row, whichnative2unicode(..., 'UTF-8')accepts as before.tests/+ndi/+unittest/+cloud/DecodeJwtTest.m: an offline test that needs no network or credentials. It builds JWTs locally (Base64Url viamatlab.net.base64encode) and covers payloads with 0, 1 and 2 stripped padding characters. It also includes non-ASCII characters to exercise UTF-8 decoding, and checks theexpandemailclaims.src/andtests/found no otherjavax.xml.bindusage.Testing
This change was not run locally, because MATLAB is not available in the environment where it was written (see AGENTS.md). The checking was static only, and CI is what verifies it.
Expected outcome: Cloud CI and the nightly cloud workflow stop failing at authentication. Unrelated cloud failures that this error was hiding may then show up.
🤖 Generated with Claude Code
https://claude.ai/code/session_01H3DDr2ybuwd2XoVfBEsU38
Generated by Claude Code