Skip to content

Reject line breaks in attribute types read from column comments #1711

Open

Description

@dimitri-yatsenko

DataJoint records each attribute's declared type, such as int32 or <blob>, at the start of the column's comment in the database (:type:comment). Heading reads it back with

special = re.match(r":(?P<type>[^:]+):(?P<comment>.*)", comment)

(src/datajoint/heading.py, line 525 on master and next). [^:]+ also matches line breaks, so the type read from a comment can span several lines. Nothing downstream checks it:

  • For a codec type (<...>), the multi-line text fails the codec pattern and stays in attr.type.
  • For a core type, it goes to attr.original_type.
  • Job._generate_definition (src/datajoint/jobs.py, line 216) writes name : <original_type or type> for each inherited primary-key attribute. So a line break in a column comment adds lines to the jobs table's definition.

Since 2.3.6, foreign-key references are never evaluated, so the added lines cannot run code; see GHSA-gmj8-m8g8-9wg9. They can still add attributes or references to the jobs table definition, or make creating the jobs table fail.

Proposed fix

  • Read the type with a pattern that excludes line breaks, for example :(?P<type>[^:\n\r]+):.
  • Accept a type from a comment only if it matches a known core type or the codec pattern. Otherwise treat the whole comment as a plain comment.
  • Have Job._generate_definition refuse any attribute name or type that contains a line break, with a DataJointError that names the table and attribute.

Tests

  • A column comment :int32 + line break + -> Other: on an inherited primary-key attribute does not add a line to Job(table).definition.
  • The same with :<blob> + line break.
  • Ordinary comments, core types and codec types still round-trip through describe().

Activity

  1. added this to the v2.3.7 milestone on Nov 20, 2026
  2. added
    bugIndicates an unexpected problem or unintended behavior
    on Nov 20, 2026
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

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions