Skip to content

Handle some uncaught exceptions in explain mode - #2539

Open
yonatan wants to merge 3 commits into
souffle-lang:masterfrom
yonatan:fix-explain-valueread
Open

Handle some uncaught exceptions in explain mode#2539
yonatan wants to merge 3 commits into
souffle-lang:masterfrom
yonatan:fix-explain-valueread

Conversation

@yonatan

@yonatan yonatan commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

Explain mode passes some user input directly to stoi() and friends, which makes it crash on user errors/typos.

For example:

path
===============
1	2
1	3
1	4
1	5
2	3
2	4
2	5
3	4
3	5
4	5
===============

Explain is invoked.
Enter command > explain path("asd", 123)
stoll
*CRASH*

Explain is invoked.
Enter command > explainnegation path(1,6)
1: path(x,y) :- 
   edge(x,y).

2: path(x,z) :- 
   edge(x,y),
   path(y,z).

Pick a rule number: xcvb
stoi
*CRASH*

And with this patch:

Enter command > explain path(1,"Asd")
Invalid argument "Asd" for type 'i'
Enter command > explainnegation path(1,6)
1: path(x,y) :- 
   edge(x,y).

2: path(x,z) :- 
   edge(x,y),
   path(y,z).

Pick a rule number: asd
Invalid rule number
Enter command > 

yonatan added 2 commits April 11, 2025 22:56
…ypes)

Catch exceptions from stoi and friends in valueRead and rethrow them with
actionable error messages, to be caught and handled in the interactive command
loop.
@codecov

codecov Bot commented Apr 11, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.72727% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.06%. Comparing base (94ccab0) to head (8cd7e04).
⚠️ Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
src/include/souffle/provenance/Explain.h 50.00% 15 Missing ⚠️
src/include/souffle/provenance/ExplainProvenance.h 42.85% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2539      +/-   ##
==========================================
- Coverage   81.14%   81.06%   -0.09%     
==========================================
  Files         492      492              
  Lines       33372    33392      +20     
==========================================
- Hits        27080    27068      -12     
- Misses       6292     6324      +32     
Files with missing lines Coverage Δ
src/include/souffle/provenance/ExplainProvenance.h 83.33% <42.85%> (-5.96%) ⬇️
src/include/souffle/provenance/Explain.h 46.25% <50.00%> (-1.14%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@quentin

quentin commented May 6, 2025

Copy link
Copy Markdown
Member

Hi, @yonatan it would be nice to have a few tests covering this improvement.

@yonatan

yonatan commented May 9, 2025

Copy link
Copy Markdown
Contributor Author

True, but I probably won't get around to it

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