Skip to content

Parsing large numbers with 1e12 notation fail #144

Closed

Description

@jverhoeks

Example code:

athena_workgroups = {
  workgroup = {
    selected_engine_version        = "Athena engine version 3"
    bytes_scanned_cutoff_per_query = 1e12 # 1 TB = $5 as an upper limit
  }
}

Gives the following error:

lark.exceptions.UnexpectedToken: Unexpected token Token('__ANON_3', 'e12') at line 4, column 39.

Activity

  1. baer95 commented on Jan 9, 2025

    @baer95

    I just ran into the same issue with the following code:

    resource "datadog_monitor" "my_monitor" {
      name         = "test-monitor"
      message      = "error rate is too high"
      type.        = "query alert"
      query        = "(does not matter)"
    
      monitor_thresholds {
        warning  = 4e-06
        critical = 0.01
      }
    }
    

    And the following error:

    Traceback (most recent call last):
      File "/opt/hostedtoolcache/Python/3.[12](https://github.mpi-internal.com/bnl/terraform-datadog/actions/runs/8741481/job/27979185?pr=2817#step:6:13).1/x64/lib/python3.12/site-packages/lark/parsers/lalr_parser_state.py", line 77, in feed_token
        action, arg = states[state][token.type]
                      ~~~~~~~~~~~~~^^^^^^^^^^^^
    KeyError: 'NAME'
    
    During handling of the above exception, another exception occurred:
    
    ... (rest of the stack trace left out for brevity)
    
    File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/lark/parsers/lalr_parser_state.py", line 80, in feed_token
        raise UnexpectedToken(token, expected, state=self, interactive_parser=None)
    lark.exceptions.UnexpectedToken: Unexpected token Token('NAME', 'critical') at line 58, column 5.
    Expected one of: 
    	* LBRACE
    

    Applying the following change fixed the error:

    -    warning  = 4e-06
    +    warning  = 0.000004

    We are using python-hcl2==5.1.1 and lark==1.2.2. Since this is an exception with Lark, I think that we should report this issue to Lark.

  2. added a commit that references this issue on Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions