Skip to content

Conversation

kenrowland
Copy link
Contributor

@kenrowland kenrowland commented Sep 22, 2025

Added try/catch around initialization to capture and log exceptions

Signed-Off-By: Kenneth Rowland kenneth.rowland@lexisnexisrisk.com

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

@Copilot Copilot AI review requested due to automatic review settings September 22, 2025 19:51
Copy link
Contributor

@Copilot 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 fixes error handling in the Elastic metrics sink by adding exception handling during the configuration initialization phase, specifically to catch and log exceptions that may occur during password decryption operations.

Key Changes

  • Added try/catch block around the entire configuration initialization logic in getHostConfig()
  • Added logging for both known IException instances and unknown exceptions during configuration

Comment on lines 155 to 158
StringBuffer errorMsg;
e->errorMessage(errorMsg);
WARNLOG("ElasticMetricSink: Exception during configuration, error=%d, message=%s", e->errorCode(), errorMsg.str());
e->Release();
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

Consider using RAII pattern with Owned<IException> instead of manual Release() call to ensure automatic cleanup even if an exception occurs between catching and releasing.

Suggested change
StringBuffer errorMsg;
e->errorMessage(errorMsg);
WARNLOG("ElasticMetricSink: Exception during configuration, error=%d, message=%s", e->errorCode(), errorMsg.str());
e->Release();
Owned<IException> ownedE = e;
StringBuffer errorMsg;
ownedE->errorMessage(errorMsg);
WARNLOG("ElasticMetricSink: Exception during configuration, error=%d, message=%s", ownedE->errorCode(), errorMsg.str());

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

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

Please respond to this suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted input pointer to an Owned and let normal destructor handle release

Copy link

Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-34917

Jirabot Action Result:
Workflow Transition To: Merge Pending
Updated PR

@kenrowland kenrowland changed the base branch from master to candidate-9.14.x September 23, 2025 13:01
Copy link
Member

@rpastrana rpastrana left a comment

Choose a reason for hiding this comment

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

@kenrowland this change was difficult to review because the entire block within the new try showed up as new. Were there any changes in that logic?
Also, left a couple of minor comments.
Consider the change Copilot suggested.

{
StringBuffer errorMsg;
e->errorMessage(errorMsg);
WARNLOG("ElasticMetricSink: Exception during configuration, error=%d, message=%s", e->errorCode(), errorMsg.str());
Copy link
Member

Choose a reason for hiding this comment

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

Very minor, but this exception is encountered during load time, not during configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this and generic catch log messages to "initialization"

Copy link
Member

@rpastrana rpastrana left a comment

Choose a reason for hiding this comment

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

@kenrowland a couple of outstanding comments

Comment on lines 155 to 158
StringBuffer errorMsg;
e->errorMessage(errorMsg);
WARNLOG("ElasticMetricSink: Exception during configuration, error=%d, message=%s", e->errorCode(), errorMsg.str());
e->Release();
Copy link
Member

Choose a reason for hiding this comment

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

Please respond to this suggestion.

Copy link
Member

@rpastrana rpastrana left a comment

Choose a reason for hiding this comment

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

@kenrowland seems ready to move forward, go ahead and squash

@kenrowland
Copy link
Contributor Author

@ghalliday Please merge

Copy link
Member

@ghalliday ghalliday left a comment

Choose a reason for hiding this comment

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

@kenrowland one minor comment. Please squash the change in.

Owned<IException> ex = e;
StringBuffer errorMsg;
ex->errorMessage(errorMsg);
WARNLOG("ElasticMetricSink: Exception during initialization, error=%d, message=%s", e->errorCode(), errorMsg.str());
Copy link
Member

Choose a reason for hiding this comment

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

Minor: Should be OWARNLOG - i.e. operator as the audience rather than the user. Same below.

…ryption

Added try/catch around initialization to capture and log exceptions

Signed-Off-By: Kenneth Rowland kenneth.rowland@lexisnexisrisk.com
@kenrowland
Copy link
Contributor Author

@ghalliday Changed as requested. Also changed other warning log messages to OWARNLOG since they too are not for the user.

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.

3 participants