diff mbox series

[1/2] cooker: Write variables that are not JSON types to the event log

Message ID 20261120135323.2627478-2-stondo@gmail.com
State New
Headers show
Series fetch/npm: no npm executable, and an event log fix | expand

Commit Message

Stefano Tondo Nov. 20, 2026, 1:53 p.m. UTC
From: Stefano Tondo <stefano.tondo.ext@siemens.com>

EventWriter.write_variables() writes the history of all variables to
the event log as JSON. A variable can hold a Python object. For
example, sstate.bbclass stores compiled regular expressions in
_SSTATE_EXCLUDEDEPS_SYSROOT during a build. When the same server runs
a second build, json.dumps() fails:

  TypeError: Object of type Pattern is not JSON serializable

This occurs with tinfoil, for example in "recipetool create", which
starts more than one build in one server.

Write such values as strings.

Signed-off-by: Stefano Tondo <stefano.tondo.ext@siemens.com>
---
 lib/bb/cooker.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Purdie Nov. 20, 2026, 6:46 p.m. UTC | #1
On Fri, 2026-11-20 at 14:53 +0100, Stefano Tondo via bitbake-devel wrote:
> From: Stefano Tondo <stefano.tondo.ext@siemens.com>
> 
> EventWriter.write_variables() writes the history of all variables to
> the event log as JSON. A variable can hold a Python object. For
> example, sstate.bbclass stores compiled regular expressions in
> _SSTATE_EXCLUDEDEPS_SYSROOT during a build. When the same server runs
> a second build, json.dumps() fails:
> 
>   TypeError: Object of type Pattern is not JSON serializable
> 
> This occurs with tinfoil, for example in "recipetool create", which
> starts more than one build in one server.
> 
> Write such values as strings.

This worries me a bit (well, a lot!), specifically the "second build"
piece. Why is this persisting across builds? Does:

https://git.openembedded.org/bitbake/commit/?id=606786d17351534ce35d1b0f89815461546a66fe

have any effect on that?

Cheers,

Richard
diff mbox series

Patch

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index a6bc2827d..abc516649 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -124,7 +124,7 @@  class EventWriter:
 
     def write_variables(self):
         with self._open() as f:
-            f.write("%s\n" % json.dumps({ "allvariables" : self.cooker.getAllKeysWithFlags(["doc", "func"])}))
+            f.write("%s\n" % json.dumps({ "allvariables" : self.cooker.getAllKeysWithFlags(["doc", "func"])}, default=str))
 
     def send(self, event):
         with self._open() as f: