Case-only differences in type names make generated files overwrite each other on case-insensitive filesystems

Open
#414 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
build-system

Research direction

Start by tracing nnvg's output path generation and write flow; the issue points to no specific source file or test. Check how generated paths are represented across target languages, then add coverage for case-only path collisions and verify generation fails before writing either file on a case-insensitive comparison. Done means the collision is rejected consistently on every filesystem and existing non-colliding outputs still work.

Written by the indexing model from the issue text.

Description

C C++ Python

Summary

Two DSDL types whose full names differ only in letter case, e.g. ns.Foo.1.0 and ns.foo.1.0, generate output files whose paths differ only in case (Foo_1_0.h, foo_1_0.h). On a case-insensitive filesystem, the default on macOS and Windows, one file silently overwrites the other. nnvg exits 0, and one type's generated code is lost. This affects every target language.

Reproduce

On main at ed853f9, in ghcr.io/opencyphal/toxic:tx26.4.1:

mkdir -p d/ns
printf 'uint8 a\n@sealed\n'  > d/ns/Foo.1.0.dsdl
printf 'uint16 b\n@sealed\n' > d/ns/foo.1.0.dsdl   # needs a case-sensitive filesystem for the sources
nnvg --target-language=c --outdir out d/ns         # exits 0
  • Output on a case-sensitive filesystem (Linux): out/ns/Foo_1_0.h and out/ns/foo_1_0.h. Python likewise produces Foo_1_0.py and foo_1_0.py.
  • Output on a case-insensitive filesystem (--outdir on a macOS volume): only out/ns/Foo_1_0.h exists, and it contains uint16_t b, which is foo's field. Foo's header was overwritten without any error.

Why it isn't caught

pydsdl rejects names that differ only in case, but only while resolving a reference to a type (DataTypeNameCollisionError in _data_type_builder.py). Two target types that don't refer to each other are never compared. Nunavut doesn't check its own output paths either.

Proposal

Before writing anything, refuse generation when two files the run would write have paths that are equal when compared case-insensitively. Check on every filesystem, so the result doesn't depend on where nnvg runs. This applies to all target languages, and changes C and C++ behavior: they refuse instead of silently overwriting.

Context

This comes from the design for #403 (decision D4). There, case-only collisions among the merged members of a Python namespace file are refused and can't be overridden with --force. Detecting them within a single run, for every language, was split out into this issue because it changes C and C++ behavior.

Dominant language
Python
Stars
48
Forks
26
Avg merge
1d 18h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenCyphal/nunavut

All issues in OpenCyphal/nunavut

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.