@@ -48,6 +48,13 @@ pub struct PostRunFingerprint {
4848 /// Outer key is the glob pattern, inner map is the match-set at execution
4949 /// time (name -> value hash). Validated at cache lookup by re-matching
5050 /// against the current env context and comparing the resulting set.
51+ ///
52+ /// Non-UTF-8 env names are never matched, saved, or treated as errors:
53+ /// they are not returned to the client, so their existence cannot affect
54+ /// task behavior. Values are stricter. A matched env must have a UTF-8
55+ /// value; the JS client errors when querying a matched non-UTF-8 value,
56+ /// and cache-hit validation treats a currently matched non-UTF-8 value as
57+ /// a changed mismatch so stale cached output is not replayed.
5158 pub tracked_env_globs : BTreeMap < Str , BTreeMap < Str , EnvValueHash > > ,
5259}
5360
@@ -534,4 +541,23 @@ mod tests {
534541 other => panic ! ( "expected changed tracked env glob mismatch, got {other:?}" ) ,
535542 }
536543 }
544+
545+ #[ test]
546+ fn validate_ignores_non_utf8_tracked_env_glob_names ( ) {
547+ let mut tracked_env_globs = BTreeMap :: new ( ) ;
548+ tracked_env_globs. insert ( Str :: from ( "PROBE_*" ) , BTreeMap :: new ( ) ) ;
549+ let fingerprint = PostRunFingerprint { tracked_env_globs, ..PostRunFingerprint :: default ( ) } ;
550+
551+ let mut unfiltered_envs = FxHashMap :: default ( ) ;
552+ unfiltered_envs. insert (
553+ Arc :: < OsStr > :: from ( non_utf8_os_string ( ) ) ,
554+ Arc :: < OsStr > :: from ( OsStr :: new ( "value" ) ) ,
555+ ) ;
556+
557+ let workspace_root = vite_path:: current_dir ( ) . expect ( "cwd" ) ;
558+ let mismatch =
559+ fingerprint. validate ( & workspace_root, & unfiltered_envs) . expect ( "validation succeeds" ) ;
560+
561+ assert ! ( mismatch. is_none( ) ) ;
562+ }
537563}
0 commit comments