Skip to content

feat: show python syntax-error message if a NameError occurs#63085

Merged
raisedadead merged 1 commit intofreeCodeCamp:mainfrom
ojeytonwilliams:feat/expand-python-errors
Oct 28, 2025
Merged

feat: show python syntax-error message if a NameError occurs#63085
raisedadead merged 1 commit intofreeCodeCamp:mainfrom
ojeytonwilliams:feat/expand-python-errors

Conversation

@ojeytonwilliams
Copy link
Copy Markdown
Contributor

This might be an issue if we need to have learner code generate errors, but we can deal with that if it happens

Checklist:

Closes #62861

This might be an issue if we need to have learner code generate errors, but we can deal with that if it happens
@ojeytonwilliams ojeytonwilliams requested a review from a team October 27, 2025 14:46
@github-actions github-actions bot added the platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. label Oct 27, 2025
Copy link
Copy Markdown
Member

@raisedadead raisedadead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these the only "kinds" of errors we want to group?

@ojeytonwilliams
Copy link
Copy Markdown
Contributor Author

That's a good question and I'm not sure. I'll give some context to make sure we're on the same page.

As it stands, if the learner's code raises an exception, then all the tests fail. Prior to this PR, only exceptions which prevented the code being evaluated generated a special message, because the test messages (e.g. "foo() should equal 5") would be misleading (the problem is you've got bad indentation or a syntax error).

The 'fix' here is a little sketchy because, in principle, you might want to write a test that fails with a NameError.

I think the best approach is to extend the test runner, so it can differentiate between "initial learner code raised an exception" and "at some point during user code evaluation or test evaluation an exception was raised" (which is how it currently behaves.). That's not something I will have time to finish today. If we want an immediate fix, we can use this, but if it can wait a week or so, I can update the runner.

Also, to directly answer your question, if we update the runner, then I think we'd want to show the special message whenever the learner's code raised any kind of python exception during initial evaluation.

@ilenia-magoni @Dario-DC any thoughts?

@Dario-DC
Copy link
Copy Markdown
Contributor

It can be a bit confusing seeing a special message just for some errors but probably it can wait. I think it would be nice to show a dedicated message any time the user's code raises an exception (and I would keep a different message for IndentationErrors).

@ojeytonwilliams
Copy link
Copy Markdown
Contributor Author

Thanks, Dario. Just to confirm: you're okay with this PR as a temporary measure and the proposed test-runner updates that would replace it?

Copy link
Copy Markdown
Contributor

@Dario-DC Dario-DC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing against it 👍

@raisedadead raisedadead merged commit 77ea476 into freeCodeCamp:main Oct 28, 2025
12 checks passed
@ojeytonwilliams ojeytonwilliams deleted the feat/expand-python-errors branch October 28, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: learn UI side of the client application that needs familiarity with React, Gatsby etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hint message that error is present does not appear

3 participants