diff --git a/qastle/linq_util.py b/qastle/linq_util.py
index 1435d94..c62410b 100644
--- a/qastle/linq_util.py
+++ b/qastle/linq_util.py
@@ -85,6 +85,8 @@ class InsertLINQNodesTransformer(ast.NodeTransformer):
             function_name = node.func.id
             if function_name not in linq_operator_names:
                 return self.generic_visit(node)
+            if len(node.args) == 0:
+                raise SyntaxError('LINQ operators must specify a data source to operate on')
             source = node.args[0]
             args = node.args[1:]
         else:

Require LINQ operator nodes to have at least one argument
[This line](https://github.com/iris-hep/qastle/blob/4617415f0e79846cac4860411353fcb2ff0fca83/qastle/linq_util.py#L88) will throw an `IndexError` if a LINQ operator node has zero arguments. This is okay, but it would be a bit better to throw a more specific and descriptive `SyntaxError` before getting there.
diff --git a/tests/test_linq_util.py b/tests/test_linq_util.py
index 4100824..e732989 100644
--- a/tests/test_linq_util.py
+++ b/tests/test_linq_util.py
@@ -35,6 +35,11 @@ def test_visit_call_name_linq_operator():
     assert_ast_nodes_are_equal(final_ast, expected_ast)
 
 
+def test_visit_call_name_linq_operator_no_source():
+    with pytest.raises(SyntaxError):
+        insert_linq_nodes(ast.parse("First()"))
+
+
 def test_visit_call_generic():
     initial_ast = ast.parse('None()')
     final_ast = insert_linq_nodes(initial_ast)

pip install -e .
parse_log_pytest
requirements.txt
pytest
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
exceptiongroup==1.2.2
importlib-metadata==6.7.0
iniconfig==2.0.0
lark-parser==0.12.0
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
-e git+https://github.com/iris-hep/qastle.git@d1b17a0f92142a4953d8866f25ddd5a7f0f3c08f#egg=qastle
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0

name: qastle
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - lark-parser==0.12.0
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/qastle

tests/test_linq_util.py::test_visit_call_name_linq_operator_no_source
tests/test_linq_util.py::test_visit_call_attribute_generic tests/test_linq_util.py::test_visit_call_attribute_linq_operator tests/test_linq_util.py::test_visit_call_name_generic tests/test_linq_util.py::test_visit_call_name_linq_operator tests/test_linq_util.py::test_visit_call_generic tests/test_linq_util.py::test_where tests/test_linq_util.py::test_where_bad tests/test_linq_util.py::test_select_bad tests/test_linq_util.py::test_selectmany tests/test_linq_util.py::test_selectmany_bad tests/test_linq_util.py::test_first tests/test_linq_util.py::test_first_bad tests/test_linq_util.py::test_aggregate tests/test_linq_util.py::test_aggregate_bad tests/test_linq_util.py::test_count tests/test_linq_util.py::test_count_bad tests/test_linq_util.py::test_max tests/test_linq_util.py::test_max_bad tests/test_linq_util.py::test_min tests/test_linq_util.py::test_min_bad tests/test_linq_util.py::test_sum tests/test_linq_util.py::test_sum_bad
qastle/linq_util.py
qastle/linq_util.py