Skip to content

False positive warning for array index access in event context (e.g., github.event.commits[0]) #244

@ericsciple

Description

@ericsciple

Problem

When accessing array elements in event payloads using index syntax, the language service produces a false positive warning:

Context access might be invalid: 0

To Reproduce

on: push
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: echo ${{ github.event.commits[0].message }}

This shows the warning even though commits is a valid array property of the push event payload.

Expected behavior

No warning should be shown for valid array index access on known array properties.

Actual behavior

Warning: Context access might be invalid: 0

Root cause (likely)

The expression evaluator validates property access but doesn't properly handle numeric array indices. When encountering commits[0], it treats 0 as a property name lookup on the commits dictionary/array, and since there's no key named "0", it warns.

Related

This was discovered while verifying issue #97 is fixed. The original issue (#97) about github.event.head_commit.message is now working correctly, but array access remains problematic.

Package/Area

  • Expressions
  • Language Service
  • Language Server
  • Workflow Parser

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions