Solved pkg: NOT NULL constraint failed: packages.desc

dvl@

Developer
I gotta a problem. I updated the packages on a host (FreeBSD 14.3 - yes, past EOL) - it's running on latest/head, not quarterly.

I got into a problem situation. Right now, pkg is unhappy. Every pkg command I have tired gives this:

Code:
root@ava-paste-01prd:/var/cache/pkg # pkg-static install -f pkg
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
Updating [my local] repository catalogue...
Fetching meta.conf: 100%     168 B   0.2 kB/s    00:01  
Fetching data: 100%   915 KiB 936.7 kB/s    00:01  
Processing entries:  17%
pkg-static: sqlite error while executing INSERT OR REPLACE INTO packages (origin, name, version, comment, desc, arch, maintainer, www, prefix, pkgsize, flatsize, licenselogic, cksum, path, manifestdigest, olddigest, vital)VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17) in file update.c:171: NOT NULL constraint failed: packages.desc
pkg-static: sqlite error while executing INSERT OR REPLACE INTO packages (origin, name, version, comment, desc, arch, maintainer, www, prefix, pkgsize, flatsize, licenselogic, cksum, path, manifestdigest, olddigest, vital)VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17) in file update.c:175: not an error
Processing entries:  18%
Unable to update repository [my local]
Error updating repositories!
root@ava-paste-01prd:/var/cache/pkg #
 
Nice one.
So I think /var/cache/pkg is where the fetched stuff lives, the sqlite stuff in /var/db/pkg.

Have you tried something like "mv /var/db/pkg /var/db/pkg.ORIG && pkg-static -f bootstrap" to essentially start pkg from a clean slate? It may give a different result, if not it may indicate a relationship with 14.3.

This is all just speculation on my part but it's something I would do.
 
name TEXT NOT NULL,
version TEXT NOT NULL,
comment TEXT NOT NULL,
desc TEXT NOT NULL,
arch TEXT NOT NULL,
maintainer TEXT NOT NULL,
prefix TEXT NOT NULL,
pkgsize INTEGER NOT NULL,
flatsize INTEGER NOT NULL,
licenselogic INTEGER NOT NULL,
cksum TEXT NOT NULL,
path TEXT NOT NULL,

you may inspect the json file from data.pkg (in the data.pkg tar is named data)
and see which one is null with jq
 
Found it.

As mentioned above, it's a private repo, not FreeBSD.

The cause: An empty, but present, pkg-descr for one of the private ports in that repo.

How did I find it, with a little help from my friend:

Code:
$ fetch https://our.repo.example.com/packages/143R-head/data.pkg
$ tar -xzf data.pkg
$ ls -lt
total 5012
-rw-r--r--  1 dalangil 6002  780432 Nov 16 20:08 data.pkg
-rw-r--r--  1 dalangil 6002 4318198 Nov 16 20:08 data
-rw-r--r--  1 dalangil 6002     513 Jan  1  1970 signature
$ file data
data: JSON text data
$ jq 'keys' data
[
  "expired_packages",
  "groups",
  "packages"
]
$ jq '.packages[0] | keys' data
[
  "abi",
  "annotations",
  "arch",
  "categories",
  "comment",
  "deps",
  "desc",
  "flatsize",
  "licenselogic",
  "licenses",
  "maintainer",
  "name",
  "origin",
  "path",
  "pkgsize",
  "prefix",
  "repopath",
  "sum",
  "version",
  "www"
]
$ jq '.packages[] | select(.desc == null)' data
[redacted]

This printed out the information for the port with no desc value

From there, I used the origin field to indentify the guilty port.

From history, that file was created, empty, on Mar 31 16:22:21 2025 and didn't become apparent as a problem until recently.

Content was added to the file, saying it should never be empty with links to this post and to the internal ticket. Building again with poudriere -C solved the issue.

Thank you for coming to my TED talk.
 
Back
Top