Back to the Media Job Compiler journey

DecidedStop 5 of 13

Turning a provider’s list of fields into strict rules

Before an image or video job can be approved, Media Job Compiler turns the provider’s list of fields into strict rules. It saves that exact translation, so later checks use the same one.

The question

Media Job Compiler prepares image and video jobs for approval. Each job holds the values it would send to the provider. I call these the job data. Before approval, the compiler checks the job data against the provider’s rules. Those rules come from a lookup tool, as a list of fields. Each field has a name, a type written as text and a mark that says if it is required. A type written as text, such as “a list, or no value”, is clear to a person. But it is not in the standard rule format that the Media Job Compiler · The compilerData checkChecks the job’s data against those rules before the approval step is built.See it in the Media Job Compiler build reads.

What I chose

I translate the list of fields first, in a Media Job Compiler · The compilerField list translatorTurns the flat list of fields from the lookup tool, which fetches each provider’s rules, into rules the checker supports. It writes them in the 2020-12 draft of a published standard for data rules.See it in the Media Job Compiler build written for that lookup tool. That way the data checker needs no special case. The translator starts by checking that three things agree. They are the provider’s web address that was asked for, the address that came back, and the tested Media Job Compiler · The compilerConnector choicePicks a provider connector only when what the provider can do, how jobs are sent and the price all match one the tool supports.See it in the Media Job Compiler build. A provider connector is the code that puts a job into this provider’s format. Then the translator builds a set of rules for one object. It writes them in the 2020-12 draft of a published standard for rules about A technical wordJSONA common text format that programs use to send each other structured data., a common text format for data. The required marks become one list at the top. A field that may have no value is written out as a choice of types. Extra fields are not allowed.

Anything unclear stops the job before approval. That includes type mixes it does not know, repeated names and required marks that disagree. An optional list with incomplete rules for its items stays in the translation. But it is forbidden in the job data. Nothing is guessed about what the provider accepts.

Why I keep the translation

Job data that passes fits a set of rules. That does not say which set. So the compiler keeps the translation with the job. This Media Job Compiler · The compilerJob fingerprintsSaves a fingerprint of the raw field list and of the translated rules with the job. It also records the connector and the translator version.See it in the Media Job Compiler build holds the raw field list and the translated rules. It holds a fingerprint of each, a short code that changes if the content does. It also holds the provider connector and the translator version. When the job reaches its Media Job Compiler · The compilerExecution checksCompares the saved fingerprints, and checks each media file is matched exactly, before the job goes to the program that runs it.See it in the Media Job Compiler build, they compare it with the translation that was reviewed. Change the field list or the translator version and the fingerprints change, even if the job data still passes.

How it’s tested

Focused tests guard against old bugs coming back. They cover lists of text that may have no value, and type mixes it does not support. They also cover repeated names and web addresses that do not match. Others cover changes to the field list or the translator version.