Skip to content

Generated REST controller does not compile when a file is ASSIGNed to a literal path ("./TEST-FILE" -> @RequestBody ./testFileDTO) #3957

Description

@squid-protocol

Found while preparing the opensourcecobol4j fresh estate (#3806, epic #3803): pre-trial generation, no porting. The generated jp-compat project does not compile (mvn -o compile, JDK 17). All 8 of its "Allow no file open (I-O / EXTEND ...)" programs fail.

Defect

generate_rest_controller (gitgalaxy/tools/cobol_to_java/cobol_to_java_api_contract_forge.py) builds Java names from a program's file inputs by only splitting on -. If a program SELECTs a file ASSIGNed to a literal path, the path goes straight into the Java source, e.g. ASSIGN "./TEST-FILE". PC dialects (GnuCOBOL, opensourcecobol4j, Micro Focus) use that form, and so does any ASSIGN to "data/in.dat". The result is:

    public ResponseEntity<?> executeAsgpath(
        @RequestBody ./testFileDTO ./testFileData      // <identifier> expected
    ) {

The batch branch has the same flaw (dd_name_raw goes into the variable and @RequestParam names unsanitised).

Minimal reproduction (origin/main 3f8bdb6)

mkdir -p estate
cat > estate/ASGPATH.cbl <<'COB'
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ASGPATH.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT TEST-FILE ASSIGN "./TEST-FILE"
                  ORGANIZATION SEQUENTIAL
                  FILE STATUS F-STATUS.
       DATA DIVISION.
       FILE SECTION.
       FD TEST-FILE.
       01 TEST-RECORD PIC X(10).
       WORKING-STORAGE SECTION.
       77 F-STATUS PIC X(02).
       PROCEDURE DIVISION.
           OPEN I-O TEST-FILE.
           DISPLAY F-STATUS.
           CLOSE TEST-FILE.
           STOP RUN.
COB
python -c "import sys; sys.argv=['r','estate','--scan']; from gitgalaxy.cobol_refractor_controller import main; main()"
python -c "import sys,glob; sys.argv=['j',glob.glob('estate_gitgalaxy_clean_*')[0]]; from gitgalaxy.cobol_to_java_controller import main; main()"
grep -rn RequestBody estate_gitgalaxy_java_spring_*/src/main/java/com/gitgalaxy/modernized/controller/
# -> AsgpathController.java:18:        @RequestBody ./testFileDTO ./testFileData

Expected: a valid Java identifier (e.g. TestFileDTO testFileData). The best source is the SELECT's file name (TEST-FILE), not the ASSIGN text. Otherwise the ASSIGN text should be reduced to identifier characters, and the generated project should compile.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5

Activity

  1. added a commit that references this issue on Sep 29, 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

    bugUnintended behavior or logic failure in the enginelegacy-modernizationCOBOL refractor, dead-code extraction, and JCL forgingpriority: medium

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions