Skip to content

Julia: concore_read crashes on valid wire payloads (nested lists, tuples, strings) #713

Open

Description

@Saswatsusmoy

Description

The README wire format lists nested arrays, tuples, strings and booleans as supported payload types, and names Julia among the implementations that parse this shared format. The Julia safe_parse_list only handles a flat list of numbers. It splits the payload on commas and calls tryparse(Float64, ...) on each token, so anything else raises an ArgumentError.

concore_read does not catch that error. When a peer writes one of these payloads, the Julia node stops with an exception instead of falling back to initstr. Python and C++ (since #460 for #389) parse these payloads, and on a parse failure both fall back to the default value instead of stopping.

Steps to reproduce

On dev (8f3e444), with CONCORE pointing at the checkout:

mkdir -p repro/out1 && cd repro

cat > writer.py <<'EOF'
import sys
sys.path.insert(0, sys.argv[1])
import concore
concore.delay = 0
concore.simtime = 5.0
concore.outpath = "./out"
concore.write(1, "ym", [[1.0, 2.0], 3.0])
EOF

cat > reader.jl <<'EOF'
include(joinpath(ARGS[1], "concore.jl"))
using .Concore
Concore.delay = 0.0
Concore.inpath = "./out"
ym = concore_read(1, "ym", "[0.0, 0.0, 0.0]")
println("ym = ", ym)
EOF

python writer.py "$CONCORE"
cat out1/ym                    # [5.0, [1.0, 2.0], 3.0]
julia reader.jl "$CONCORE"

Expected behavior

The Julia node reads the value. C++ returns [1, 2, 3] for this file, and Python returns [[1.0, 2.0], 3.0]. If the payload really cannot be parsed, the read should fall back to initstr, the same as in the other runtimes.

Actual behavior

ERROR: LoadError: ArgumentError: safe_parse_list: cannot parse '[1.0' as Float64 (position 2 in '[5.0, [1.0, 2.0], 3.0]')
Stacktrace:
 [1] safe_parse_list(str::String)
   @ Main.Concore concore.jl:536
 [2] concore_read(port::Int64, name::String, initstr::String)
   @ Main.Concore concore.jl:712

The process exits with status 1.

Other payloads

The same Python writer, read back by the Julia and C++ nodes:

Payload passed to concore.write File contents Julia concore_read C++ read
[1.0, 2.0] [5.0, 1.0, 2.0] [1.0, 2.0] [1, 2]
[[1.0, 2.0], 3.0] [5.0, [1.0, 2.0], 3.0] throws [1, 2, 3]
[1.0, (2.0, 3.0)] [5.0, 1.0, (2.0, 3.0)] throws [1, 2, 3]
['ok', 1.0] [5.0, 'ok', 1.0] throws [1]
'ok' ok throws falls back to initstr

Python only turns a top-level tuple into a list (#605), so a tuple nested inside a list is written as-is, as in the third row.

safe_parse_list also throws on these inputs, all of which ast.literal_eval accepts:

Input ast.literal_eval Julia
(5.0, 1.0, 2.0) tuple throws
[5.0, 'a,b', 1.0] list throws
[5.0, 1.0,] list throws
[] empty list throws

The initval cases in tests/protocol_fixtures/python_phase1_cases.json fail as well:

Case Expected Julia
initval/valid_list_sets_simtime: [12.5, "a", 3] simtime 12.5, payload ["a", 3] throws, simtime unchanged
initval/invalid_input_returns_empty_and_preserves_simtime: not_a_list [], simtime unchanged throws

Julia is not listed in cross_runtime_matrix.phase2.json, so these cases are not tracked for it.

Cause

  • safe_parse_list splits the inner text on , and parses each token as a Float64. Brackets, parentheses and quoted strings are not tokenized.
  • In concore_read, the call to safe_parse_list(ins) is outside any try, so a parse error propagates out of the read.
  • The ZMQ path, _zmq_read, already catches parse errors and returns initval(initstr). File-based and ZMQ reads in Julia therefore behave differently for the same payload.
  • For comparison, C++ parselist_double parses the full literal and flattens it to numbers. Python read returns the default with last_read_status = "PARSE_ERROR" when parsing fails.

concoredocker.jl has the same code and the same behavior.

Proposed fix

  1. Replace the comma split in safe_parse_list with a small recursive parser for the subset of Python literals that the other runtimes accept: numbers (including exponent notation), True/False/None, single- and double-quoted strings, nested [...] and (...), and trailing commas. Keep the existing np.float64(...)/np.array(...) handling.
  2. Keep the return type Vector{Float64} and flatten in the same way as C++ flatten_numeric: numbers kept, booleans become 1.0/0.0, strings skipped, and nested lists and tuples flattened in order. Existing Julia nodes need no changes.
  3. In concore_read and initval, fall back to initstr (or return Float64[] and leave simtime unchanged, per the fixture) when the payload cannot be parsed, matching the ZMQ path, Python and C++.
  4. Apply the same changes to concoredocker.jl.
  5. Tests: update the @test_throws cases in tests/julia/test_parser.jl whose expected behavior changes (for example []), add parser cases for each payload type above, add a Python-to-Julia interop test with a nested payload, and run the initval protocol fixtures against Julia.

Questions

  • Is flattening (the C++ behavior) the preferred result for Julia, or should concore_read return structured values the way Python does? Flattening keeps the current API. Structured values would be a breaking change for existing Julia nodes.
  • Should safe_parse_list itself still throw on malformed input such as [1.0, abc], with only concore_read and initval falling back? Keeping the public parser strict seems useful for callers who want the error.
  • Should a fallback emit a @warn? Julia currently logs nothing on the read path.

I'd like to work on this once the approach is agreed.

Related

Environment

  • concore dev at 8f3e444
  • Julia 1.10.12 and 1.13.1 (same result on both)
  • Python 3.11.17
  • Linux x86_64

Activity

  1. github-actions commented on Nov 23, 2026

    @github-actions

    👋 Welcome to the CONTROL-CORE Project, @Saswatsusmoy! Thank you for opening your first issue in concore.
    We appreciate your contribution to the organization and will review it as soon as possible.

    Before we get started, please check out these resources:

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