buildd-manager crashes on ASCII NUL in build logtail

Bug #1831500 reported by Colin Watson
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Colin Watson

Bug Description

If a build emits ASCII NUL to its log, then buildd-manager fails the build with this traceback in the log:

Traceback (most recent call last):
  File "/srv/", line 1442, in gotRes

    _inlineCallbacks(r, g, deferred)
  File "/srv/", line 1386, in _inlin

    result = g.send(result)
  File "/srv/", line 486, in scan
  File "/srv/", line 1532, in unwind

    return _inlineCallbacks(None, gen, Deferred())
--- <exception caught here> ---
  File "/srv/", line 1386, in _inlin

    result = g.send(result)
  File "/srv/", line 549, in updateBuild
  File "/srv/", line 115, in __get__
    value = self.populate(instance)
  File "/srv/", line 114, in specific_build
    bfj = self._build_farm_job
  File "/srv/", line 157, in __get__
  File "/srv/", line 170, in get
  File "/srv/", line 521, in flush
  File "/srv/", line 578, in _flush_one
    self._connection.execute(expr, noresult=True)
  File "/srv/", line 306, in execu

    return Connection.execute(self, statement, params, noresult)
  File "/srv/", line 241, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "/srv/", line 316, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "/srv/", line 372, in raw_execute
    self._prepare_execution(raw_cursor, params, statement)
  File "/srv/", line 404, in _prepare_execution
    statement, params or ())
  File "/srv/", line 454, in _check_disconnect
    return function(*args, **kwargs)
  File "/srv/", line 248, in trace
    attr(*args, **kwargs)
  File "/srv/", line 684, in connection_raw_execute
    statement, tuple(connection.to_database(params)))
exceptions.ValueError: A string literal cannot contain NUL (0x00) characters.

As far as I know, PostgreSQL's text type can't hold NUL bytes at all, so this isn't just a question of different escaping. We could migrate buildqueue.logtail to be a binary type instead, but its sole purpose is to be rendered in the web UI so I don't think there's much point in doing that. We should perhaps just remove NUL bytes before storing them instead.

Related branches

Colin Watson (cjwatson)
Changed in launchpad:
status: Triaged → In Progress
assignee: nobody → Colin Watson (cjwatson)
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
Colin Watson (cjwatson)
tags: added: qa-ok
removed: qa-needstesting
Colin Watson (cjwatson)
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.