Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(docker): read a file-backed secret past a Windows editor BOM
Aashish47de5e88856e
diff --git a/docker/entrypoint.py b/docker/entrypoint.pyindex 4a5d2bf0..a902c25e 100644--- a/docker/entrypoint.py+++ b/docker/entrypoint.py@@ -16,7 +16,15 @@ def main():if not filename:continuetry:- value = Path(filename).read_text(encoding="utf-8").strip()+ # `utf-8-sig`, not `utf-8`: a secret file written by a Windows editor starts+ # with a UTF-8 byte-order mark (PowerShell 5.1's `utf8` encoding and+ # Notepad's default both write one -- this file's audience includes the+ # `os.name == "nt"` path below). Read as plain utf-8 that mark is U+FEFF,+ # which `.strip()` does not remove because it is not whitespace, so the+ # token would arrive with one leading character no consumer accepts.+ # `utf-8-sig` reads a BOM when present and plain UTF-8 otherwise, and a+ # genuine UTF-8 error still fails into the `UnicodeError` below.+ value = Path(filename).read_text(encoding="utf-8-sig").strip()except (OSError, UnicodeError, ValueError):sys.exit(f"Cannot read {name}_FILE")if not value or "\0" in value:diff --git a/tests/test_docker_entrypoint.py b/tests/test_docker_entrypoint.pyindex 04c32fd5..8344d143 100644--- a/tests/test_docker_entrypoint.py+++ b/tests/test_docker_entrypoint.py@@ -114,6 +114,36 @@ class EntrypointTests(unittest.TestCase):self.assertTrue(self.report(result, name)["matched"], result.stdout)self.assertNotIn("synthetic-file-value", result.stdout + result.stderr)+ def test_a_utf8_bom_is_not_part_of_the_secret(self):+ """A Windows editor's byte-order mark is file metadata, not the token's first character.++ PowerShell 5.1's `utf8` encoding and Notepad both write a UTF-8 BOM, and this+ entrypoint's audience includes the Windows path it runs a child on. Read as plain+ utf-8 the mark becomes U+FEFF, which `.strip()` does not remove (it is not+ whitespace), so the loaded variable carried one leading character no consumer --+ the Hub for `HF_TOKEN`, `laya-serve`'s bearer check for `LAYA_API_KEY` -- accepts.+ """+ for name in SECRET_NAMES:+ with self.subTest(secret=name):+ with tempfile.TemporaryDirectory() as directory:+ secret = Path(directory) / "token"+ secret.write_bytes(b"\xef\xbb\xbfsynthetic-file-value\n")+ result = self.invoke(name, {name + "_FILE": str(secret)}, "synthetic-file-value")+ self.assertTrue(self.report(result, name)["matched"], result.stdout)+ self.assertNotIn("synthetic-file-value", result.stdout + result.stderr)++ def test_a_file_that_is_only_a_bom_is_empty(self):+ """Stripping the BOM leaves nothing, and nothing is the empty-secret refusal, not a load."""+ for name in SECRET_NAMES:+ with self.subTest(secret=name):+ with tempfile.TemporaryDirectory() as directory:+ secret = Path(directory) / "token"+ secret.write_bytes(b"\xef\xbb\xbf")+ result = self.invoke(name, {name + "_FILE": str(secret)})+ self.assertNotEqual(result.returncode, 0)+ self.assertEqual(result.stdout, "")+ self.assertIn(name + "_FILE", result.stderr)+def test_file_variable_is_removed_before_the_command_runs(self):"""What "and the `_FILE` variable is removed before the server execs" promises, per name."""for name in SECRET_NAMES: