Skip to content

A new batch schema whose name uses its parent's lot number fails to create #271

Closed

Description

@mghent

Creating a parent schema and a batch schema in one revision fails if the batch's name template uses the parent's lot number.

Example

  • Cell Line is a parent schema.
  • Cell Line Batch has a Parent Cell Line field, a parent link to Cell Line. Its names are built from the parent and the lot number, like CL001-1.

Both schemas are new in the same revision. upgrade creates them, then stops at the name template:

Field parent_cell_line is not a parent link field. The field for type
CHILD_ENTITY_LOT_NUMBER must be a parent link field.

Why

A link field can't point at a schema that doesn't exist yet, so Liminal creates Parent Cell Line as a blank link and fills in the target later. The generated revision runs these steps:

  1. Create Cell Line.
  2. Create Cell Line Batch, with Parent Cell Line as a blank link.
  3. Set Cell Line Batch's name template to Parent Cell Line plus the lot number. This fails. A lot number needs a parent link, and Parent Cell Line is still blank.
  4. Set Cell Line Batch's naming strategy to use the template.
  5. Point Parent Cell Line at Cell Line.

Two things are wrong:

  • Step 5 should come before step 3. Liminal sorts steps by type, and name templates always sort ahead of field updates.
  • Step 5 leaves out parent_link. It sets the target but not parent_link=True. So even in the right order, Parent Cell Line would be an ordinary link, not a parent link, and step 3 would still fail.

Steps 1 and 2 have already applied when it fails, and the remote revision doesn't move.

Workaround. We edited the revision to run step 5 first, with parent_link=True added, then steps 3 and 4.

Suggested fix. For newly created schemas, set parent_link along with the link target, and run the name template and naming strategy after the link targets. Revisions that only update existing schemas would keep today's order.

Happy to open a PR with tests. Seen on 5.1.1, with #262 applied.

Activity

  1. mghent commented on Oct 29, 2026

    @mghent
    ContributorAuthor

    I've opened #272 with a fix. For new schemas, it sets the parent link first, then the name template and naming strategy, and the link step now carries parent_link. Revisions that only touch existing schemas come out the same as before.

    We tried it on our tenant with a Cell Line and Cell Line Batch pair like the example above, and it applied cleanly and rolled back cleanly.

    This fixes the new-schema case, but there could be other ordering cases. Happy to take a shot at a general ordering fix if you'd like.

  2. ndamania00 commented on Nov 4, 2026

    @ndamania00
    Collaborator

    Hey! I went ahead and built on top of the PR you created to cover the remaining NameTemplate ordering conflicts that can arise. I will do some last testing and then merge this in with the next Liminal release! #276

  3. linked a pull request that will close this issueFix update name template ordering #276on Nov 7, 2026
  4. added a commit that references this issue on Nov 13, 2026
    c88a655
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions