Skip to content

Improve LocalArtifact validation of `data` dictionary, and add `VERSION`

In local_artifact.py [1] we have different artifacts. For example, recently we've added LintianArtifact, AutopkgtestArtifact and DebianSystemTarballArtifact.

The code using this artifacts (in the worker side, e.g. MmDebstrap) follow this pattern:

artifact = DebianSystemTarballArtifact.create(system_file)

artifact.data.update({"key1": value1, "key2: value2})

self.debusine.upload_artifact(artifact)

I suggest a stronger validation of artifact.data dictionary doing two things:

Add VERSION

Add VERSION in the artifact (and keep it in self.data with artifact_version). The code consuming the artifact could check that is of an expected VERSION (I assume that we might add, remove or change the data at some point). Currently the code using an artifact needs to check if some data is there or not. The semantics might change between "versions".

Consistent validation

Add stronger and consistent validation. For some earlier artifact we had some ad-hoc validation (See metadata_contains_debs_if_binary or type_must_be_in_data).

I think that it's a good idea to define that the version 1.0 of artifacts must have certain fields (and maybe the type of the fields?) in a more generic way than just one by one. The mandatory fields might be part of the artifact definition.

In some earlier artifacts the data field was populated by the artifact itself and not externally (passing certain parameters to the artifact creation, for example) which was guaranteeing the same structure if two different code paths used the same artifact. With the latest patterns of using artifacts (see MmDebstrap, Autopkgtest tasks) two different code paths might generate the same artifact type with containing different data (which I find it confusing, specially when consuming the artifact... or even when visualizing it on a specialized view).

[1]: I'd like to refactor this file into a file per artifact type.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information