Skip to content
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

Ignore schema for all reply_ subtypes #1058

Closed
wants to merge 8 commits into from

Conversation

khyatimahendru
Copy link
Collaborator

No description provided.

@@ -728,7 +728,8 @@ private ReportingDevice validateMessageCore(Object messageObj, Map<String, Strin
writeDeviceOutCapture(messageObj, attributes, deviceId, schemaName);

String subFolder = attributes.get(SUBFOLDER_PROPERTY_KEY);
boolean processSchema = !IGNORE_FOLDERS.contains(subFolder);
boolean processSchema = !SubType.REPLY.value().equalsIgnoreCase(schemaName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the ignore case? Generally we should be pedantic about case matching (just avoids confusion elsewhere).

Also, I'm just generally confused how this works... because SubType would be reply but the schemaName would be something with a reply_ prefix? -- so they never would be equal irrespective of case, so this change seems like a no-op?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. I removed the ignore_case.

  2. Particularly for reply_update, there's this condition in function messageSchema() which would return 'reply' as the schemaName - so I had made the comparison with schemaName. I have fixed it and changed it to compare with subType instead.

  private String messageSchema(Map<String, String> attributes) {
    String subFolder = attributes.get(SUBFOLDER_PROPERTY_KEY);
    String subType = attributes.get(SUBTYPE_PROPERTY_KEY);

    if (SubFolder.UPDATE.value().equals(subFolder)) { <-------
      return subType;
    }

I need some suggestions on how I can test this change. So far, I have created a test schema under tests/traces/simple under an existing device GAT-123 with the name 005_reply_update.json.

@khyatimahendru khyatimahendru marked this pull request as draft January 16, 2025 14:08
@khyatimahendru khyatimahendru marked this pull request as ready for review January 27, 2025 11:15
@khyatimahendru khyatimahendru requested a review from grafnu January 27, 2025 15:47
@@ -798,6 +800,11 @@ public void validateDeviceMessage(ReportingDevice device, Map<String, Object> me
Map<String, String> attributes) {
String schemaName = ofNullable(attributes.get(SCHEMA_NAME_KEY)).orElseGet(
() -> messageSchema(attributes));

if (SubType.REPLY.value().equals(attributes.get(SUBTYPE_PROPERTY_KEY))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe extract this to a function shared with the other place, so that the logic behind this is only in one place!

@@ -0,0 +1,20 @@
{
"gateway" : { },
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm -- this doesn't look like the body of a reply message, it looks like a model message of some kind. Where did you get it from? Shouldn't really matter since the filter is all on the subType, but probably a good idea to have it be representative!

@@ -0,0 +1,13 @@
{
"timestamp" : "1999-10-20T01:02:03Z",
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm -- maybe I'm missing something here but I thought there would not be a reploy.out since it's filtered out?

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