Skip to content

Conversation

@laileni-aws
Copy link
Contributor

Problem

PR: #7270 introduced a bug where the isAmazonLinux2() function incorrectly identifies regular Linux/Ubuntu systems in web/container environments as Amazon Linux 2. This happens because:

  1. The function checks os.release() for .amzn2. or .amzn2int. patterns
  2. In containerized environments (like VS Code web/remote), os.release() returns the host's kernel version, not the container's OS
  3. If the host is Amazon Linux 2 but the container is Ubuntu/Linux, the function incorrectly returns true
  4. This prevents Amazon Q LSP from starting because it thinks it's on AL2 without the required GLIBC patch

Solution

  • Skip AL2 detection for web environments - Returns false immediately since web mode runs in a browser

  • Check /etc/os-release first - In containerized environments, this file contains the actual container OS, not the host OS

  • Trust container OS over kernel version - If /etc/os-release shows it's not AL2 (e.g., Ubuntu), return false regardless of kernel version

  • Fall back to kernel check only when necessary - Only use os.release() if we can't read /etc/os-release or if it confirms AL2

  • Prioritized container OS detection over kernel version detection

  • Maintained backward compatibility for actual AL2 systems

  • Added comprehensive test coverage for the new scenarios


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@laileni-aws laileni-aws requested a review from a team as a code owner September 18, 2025 21:25
@amazon-inspector-ohio
Copy link

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

@amazon-inspector-ohio
Copy link

✅ I finished the code review, and didn't find any security or code quality issues.

@laileni-aws laileni-aws changed the title fix(amazonq): isAmazonLinux2() function incorrectly identifies regular Linux/Ubuntu systems in web/container environments as AL2 fix(amazonq): isAmazonLinux2() function incorrectly identifies regular Linux/Ubuntu in web/container env as AL2 Sep 18, 2025
@laileni-aws laileni-aws reopened this Sep 18, 2025
@amazon-inspector-ohio
Copy link

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

@amazon-inspector-ohio
Copy link

✅ I finished the code review, and didn't find any security or code quality issues.

Copy link

@murkvin murkvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few comments and questions.

@laileni-aws laileni-aws requested a review from murkvin September 24, 2025 00:12
Copy link

@murkvin murkvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we can still strip away more.

@laileni-aws laileni-aws enabled auto-merge (squash) September 24, 2025 21:23
@laileni-aws laileni-aws merged commit f1e5450 into aws:master Sep 24, 2025
41 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants