Skip to content

fix(neptune): validate IRI cell values in to_rdf_graph#3369

Merged
kukushking merged 4 commits into
mainfrom
fix/neptune-validate-iri-cell-values
Jun 16, 2026
Merged

fix(neptune): validate IRI cell values in to_rdf_graph#3369
kukushking merged 4 commits into
mainfrom
fix/neptune-validate-iri-cell-values

Conversation

@kukushking

Copy link
Copy Markdown
Collaborator

Feature or Bugfix

  • Bugfix

Detail

  • Validate each IRI cell value (subject_column, predicate_column, object_column, and graph_column when present) in wr.neptune.to_rdf_graph against the SPARQL 1.1 IRIREF grammar before splicing into the generated UPDATE query. Cells containing whitespace, control characters, or any of <>"{}|^\\are rejected withInvalidArgumentValue, identifying the offending column and row index. Validation runs before any write_sparql` call, including across batches.
  • Relax four pre-existing assertions in tests/unit/test_neptune_parsing.py to be compatible with gremlinpython >= 3.8, which now returns properties=[] where prior versions returned properties=None.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Reject any DataFrame cell whose value cannot appear inside a SPARQL
IRIREF token (whitespace, control chars, or any of <>"{}|^`\), so
caller-supplied data cannot close the <...> token and inject arbitrary
SPARQL UPDATE syntax.

Validation runs before any write_sparql call and raises
InvalidArgumentValue identifying the offending column and row index.

Also relaxes four pre-existing test assertions in test_neptune_parsing
to tolerate gremlinpython >=3.8, which returns properties=[] where
prior versions returned properties=None.
@kukushking kukushking self-assigned this Jun 14, 2026
…on 3.8

gremlinpython 3.8 removed the deprecated AnonymousTraversalSource.withGraph()
method. Use the Graph().traversal() form (already used elsewhere in the same
function) so to_property_graph works on both gremlinpython <3.8 and >=3.8.
@kukushking kukushking requested a review from EthanBunce June 16, 2026 12:39
@kukushking kukushking merged commit a4e72e4 into main Jun 16, 2026
31 checks passed
@kukushking kukushking deleted the fix/neptune-validate-iri-cell-values branch June 16, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants