Skip to content

[Bug] UnboundLocalError on 8 DataFileRoute endpoints when casename/modelname is null #438

@parthdagia05

Description

@parthdagia05

Summary

Eight POST endpoints in API/Routes/DataFile/DataFileRoute.py crash with UnboundLocalError when the request body sends null for casename or modelname.

The pattern: each route checks if casename != None: and only assigns response inside that block. When casename is None, the block is skipped but return jsonify(response) still executes - response was never defined, so Python raises UnboundLocalError and Flask returns a raw 500 with a full stack trace.

Affected routes: generateDataFile, createCaseRun, updateCaseRun, deleteScenarioCaseRuns, saveView, updateViews, batchRun, cleanUp.

This is the same bug class that #252 reported and PR #253 fixed - but PR #253 only patched readDataFile and validateInputs, leaving the other eight routes unguarded. Issue #288 later reported the batchRun crash separately, confirming the incomplete coverage.

What did you expect? (optional)

No response

How can we reproduce it?

curl -X POST http://127.0.0.1:5002/generateDataFile
-H "Content-Type: application/json"
-d '{"casename": null, "caserunname": "test"}'

Returns: 500 Internal Server Error with UnboundLocalError stack trace.
Expected: 400 Bad Request with JSON error message.

Same crash on: /createCaseRun, /updateCaseRun, /deleteScenarioCaseRuns,
/saveView, /updateViews, /batchRun, /cleanUp.

Environment (optional)

Branch: main @ 5f8f89a
File: API/Routes/DataFile/DataFileRoute.py

Logs or screenshots (optional)

No response

Related issue, PR, or discussion (optional)

Proposed track

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions