Skip to content

Enforce additional check for info function #145

@sunng87

Description

@sunng87

Prometheus has some additional restrictions on info:

		if n.Func.Name == "info" && len(n.Args) > 1 {
			// Check the type is correct first
			if n.Args[1].Type() != ValueTypeVector {
				p.addParseErrf(node.PositionRange(), "expected type %s in %s, got %s", DocumentedType(ValueTypeVector), fmt.Sprintf("call to function %q", n.Func.Name), DocumentedType(n.Args[1].Type()))
			}
			// Check the vector selector in the input doesn't contain a metric name
			if vs, ok := n.Args[1].(*VectorSelector); ok && vs.Name != "" {
				p.addParseErrf(n.Args[1].PositionRange(), "expected label selectors only, got vector selector instead")
			} else if ok {
				// Set Vector Selector flag to bypass empty matcher check
				vs.BypassEmptyMatcherCheck = true
			} else {
				p.addParseErrf(n.Args[1].PositionRange(), "expected label selectors only")
			}
		}

Address this in our arity check as well.

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