Skip to content

Conversation

@shantyk
Copy link
Contributor

@shantyk shantyk commented Dec 10, 2025

The toml parsing section can throw NPE at more than one step, so added try/catch and more generic handling of exceptions during attempts to derive project name.

@shantyk shantyk self-assigned this Dec 10, 2025
@shantyk shantyk marked this pull request as ready for review January 5, 2026 13:59
@shantyk shantyk requested a review from Copilot January 6, 2026 14:49
@shantyk shantyk merged commit 64342bf into master Jan 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds defensive exception handling to prevent NullPointerExceptions when attempting to derive a project name from pyproject.toml or setup.py files. The fix wraps the TOML parsing and setup.py execution logic in try-catch blocks and adds null checks to guard against NPE conditions.

Key Changes:

  • Added null checks for tomlParseResult.getTable(PROJECT_KEY) and projectTable before accessing them
  • Wrapped TOML parsing logic in a try-catch block with debug logging
  • Wrapped setup.py execution logic in a try-catch block with debug logging

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +133 to +134
} catch (Exception e) {
logger.debug("Failed to parse project name from pyproject.toml.");
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The error message should include the exception details to aid debugging. Consider logging the exception message or using logger.debug with the exception parameter: logger.debug(\"Failed to parse project name from pyproject.toml.\", e)

Copilot uses AI. Check for mistakes.
Comment on lines +147 to +148
} catch (Exception e) {
logger.debug("Failed to parse project name from setup.py.");
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The error message should include the exception details to aid debugging. Consider logging the exception message or using logger.debug with the exception parameter: logger.debug(\"Failed to parse project name from setup.py.\", e)

Copilot uses AI. Check for mistakes.
if (executableOutput.getReturnCode() == 0) {
List<String> output = executableOutput.getStandardOutputAsList();
projectName = output.get(output.size() - 1).replace('_', '-').trim();
} catch (Exception e) {
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

Catching generic Exception is overly broad. Consider catching more specific exception types (e.g., NullPointerException, TomlParseException) to avoid masking unexpected errors that should be handled differently or propagated.

Copilot uses AI. Check for mistakes.
projectName = output.get(output.size() - 1).replace('_', '-').trim();
}
}
} catch (Exception e) {
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

Catching generic Exception is overly broad. Consider catching more specific exception types (e.g., ExecutableRunnerException, IOException) to avoid masking unexpected errors that should be handled differently or propagated.

Suggested change
} catch (Exception e) {
} catch (ExecutableRunnerException e) {

Copilot uses AI. Check for mistakes.
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.

5 participants