Skip to content

Service port autocomplete doesn't strip protocol suffix #277

@ericsciple

Description

@ericsciple

Summary

When service container ports include a protocol suffix (e.g., 8080:80/tcp), the autocomplete for job.services.<id>.ports.* incorrectly includes the protocol suffix in the port key.

Current Behavior

Given a workflow with:

services:
  redis:
    image: redis
    ports:
      - 6379:6379
      - 8080:80/tcp

Autocomplete for ${{ job.services.redis.ports.| }} shows:

  • 6379
  • 80/tcp

Expected Behavior

Autocomplete should show:

  • 6379
  • 80

This matches the runner's actual behavior - at runtime, job.services.redis.ports.80 returns the host port, not job.services.redis.ports.80/tcp.

Details

The port parsing logic in languageservice/src/context-providers/job.ts splits on : but doesn't strip the optional /tcp or /udp protocol suffix:

const portParts = item.toString().split(":");
const containerPort = portParts.length === 2 ? portParts[1] : portParts[0];

Suggested Fix

Strip the protocol suffix after extracting the container port:

const portParts = item.toString().split(":");
let containerPort = portParts.length === 2 ? portParts[1] : portParts[0];
containerPort = containerPort.split("/")[0]; // Strip protocol suffix

Metadata

Metadata

Assignees

No one assigned

    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