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

Custom rule exemption not working for fields #123

Closed
chchtv11 opened this issue Feb 24, 2023 · 7 comments
Closed

Custom rule exemption not working for fields #123

chchtv11 opened this issue Feb 24, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@chchtv11
Copy link

chchtv11 commented Feb 24, 2023

I am unable to add an exemption at the field level for custom rules. However, I can add them at the view level.

Example:

In manifest:

# rule: 3-d_value_format {
#  description: "Use of 'value_format' in dimension or measure. Use (and define if needed) 'value_format_name' instead"
#  match: "$.files[*].view.*.*.*"
#  expr_rule: (== ::match:value_format undefined) ;;
# }

In view file:

  #  LAMS
  #  rule_exemptions: {
  #   3-d_value_format: "Whatever reason"
  #  }
    type: sum
    sql: ${value} ;;
    value_format: "0.00"
  }

I understand this is similar to another issue #50 but I thought it might be specific to field-level exemptions since I can add exemptions to views.

@fabio-looker
Copy link
Contributor

Hi @chchtv11

Dimension-level exemptions seem to work fine in my testing: https://github.com/looker-open-source/look-at-me-sideways/blob/issue-123/__tests__/dummy-projects/09-exempt-custom-rules/index.test.js

image

Perhaps you could provide a more specific test case? and also confirm which version of LAMS you are running?

@chchtv11
Copy link
Author

Hi @fabio-looker thank you for looking into this. I am running LAMS v2 in github actions. I have copied the test you ran into my project (but specifying measure only, as ['dimension', 'measure'] has never worked for me)

In manifest.lkml:

# rule: types_required {
#  description: "Type must be specified"
#  match: "$.model.*.view.*.measure.*"
#  expr_rule: ( !== ::match:type undefined ) ;;
# }

In sales_target_team.view.lkml:

  measure: total_value {
    #  LAMS
    #  rule_exemptions: {
    #   types_required: "Please be exempt"
    #  }
    sql: 1 ;;
  }

As you can see it is failing
Screenshot 2023-02-27 at 16 52 34
Screenshot 2023-02-27 at 16 51 10

@fabio-looker
Copy link
Contributor

Thanks, I found a typo in my test and am now able to reproduce this. Actually I'm suprised no one has mentioned it before! I'll try to figure out the cause by the end of the week

@fabio-looker fabio-looker added bug Something isn't working and removed Repro needed labels Feb 27, 2023
@fabio-looker
Copy link
Contributor

fabio-looker commented Mar 8, 2023

I believe the cause of this is https://github.com/looker-open-source/look-at-me-sideways/blob/master/lib/custom-rule/rule-evaluator.js#L19

exempt: exempt || getExemption(modelFragment, ruleDef.$name), should be exempt: exempt || getExemption(modelFragment[pathpart], ruleDef.$name)

The symptom here is that the exemption will work at intermediate levels but not at the most granular level where matched.

I have this fixed in my v3 branch which I am hoping to release this month.

@fabio-looker
Copy link
Contributor

This is currently available in the v3 beta: https://www.npmjs.com/package/@looker/look-at-me-sideways/v/3.0.0-beta.0

Release notes: https://github.com/looker-open-source/look-at-me-sideways/blob/fabble/v3-extends-refinements/docs/release-notes/v3.md

If you do not want to upgrade to v3, let me know and I can also patch this into v2

@fabio-looker
Copy link
Contributor

fabio-looker commented May 13, 2023

Hello!

Although this was fixed in 3.0.0-beta.0 , that beta release had several issues. Many of those issues are fixed in the next beta pre-release 3.0.0-beta.1.

v3 release notes

I'll keep this issue open until v3 is out of beta. Thank you for your feedback thus far!

@fabio-looker
Copy link
Contributor

Hi @chchtv11 ,

v3 is now generally available. I'm closing out this ticket, but let me know if you have any feedback and I can reopen it as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants