Skip to content

sdk-core, node: attribute validation #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 8, 2024
Merged

Conversation

perf2711
Copy link
Contributor

@perf2711 perf2711 commented Oct 8, 2024

This PR adds attribute validation on initialize, which checks the following attributes:

  • application
  • application.version

This also removes the check from node.

@perf2711 perf2711 added the enhancement New feature or request label Oct 8, 2024
@perf2711 perf2711 requested a review from konraddysput October 8, 2024 09:40
@perf2711 perf2711 self-assigned this Oct 8, 2024
Copy link
Collaborator

@konraddysput konraddysput left a comment

Choose a reason for hiding this comment

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

Something is wrong with our node tests. I think we expect the app to fail when there is no application version or application in the attributes.

@@ -418,4 +420,51 @@ export abstract class BacktraceCoreClient<
private static destroy() {
this._instance = undefined;
}

private validateAttributes() {
function isNotEmptyString(v: unknown) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we're introducing a nice way to validate attributes, but in our scenario, we don't need such complexity. What we can do is just simply test if those two attributes are defined. Based on what we want to verify and how easily we can achieve that, wouldn't it be better if we keep the smallest/simplest solution for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how would you do this more "easily"?

Copy link
Collaborator

Choose a reason for hiding this comment

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

just simply

const attributes = this.attributeManager.ger()
const validAttributes = !!attributes["application"] && !!attributes["application.version"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

simplified a bit

@perf2711 perf2711 force-pushed the feature/attribute-validation branch from 6a5b22b to 81a438f Compare October 8, 2024 11:12
@perf2711 perf2711 merged commit d5fdd22 into main Oct 8, 2024
5 checks passed
@perf2711 perf2711 deleted the feature/attribute-validation branch October 8, 2024 11:50
@perf2711 perf2711 mentioned this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants