Skip to content

[Bug] BoundedMap.has() Returns false for Keys Storing undefined #738

Closed

Description

@akramcodez

Description

BoundedMap.has() is implemented as return this.get(key) !== undefined. get() returns undefined for two distinct reasons: (1) the key does not exist, or (2) the key exists but its stored value is undefined. This means
has() returns false for a key that was explicitly set to undefined, violating the standard Map contract where has() only reflects key existence, not value truthiness.

Environment

  • OS: Any
  • Node version: Any
  • Nanocoder version: Latest
  • Provider: N/A
  • Model: N/A

Steps to Reproduce

  1. Open source/utils/bounded-map.ts.
  2. Create a BoundedMap and call map.set('key', undefined).
  3. Call map.has('key').
  4. Observe it returns false despite the key being present.

Expected Behavior

map.has('key') should return true when the key was set, regardless of whether the value is undefined.

Actual Behavior

map.has('key') returns false because get() returns undefined and the implementation treats that as "key not found".

Logs/Screenshots

N/A

Additional Context

  • Fix: rewrite has() to check the internal Map directly and perform a manual TTL check, rather than delegating to get().
  • This matches how the native Map.prototype.has() behaves.
  • Note: This issue is intentionally kept small and is suitable for first-time contributors. If you're interested in working on it, please leave a comment below and ask to be assigned before opening a pull request.
  • I have searched existing issues to ensure this is not a duplicate
  • I can reproduce this issue consistently
  • This issue occurs with the latest version of nanocoder

Activity

  1. added
    bug
    good first issue
    on Aug 1, 2026
  2. MsadafK commented on Aug 1, 2026

    @MsadafK

    Hi @akramcodez , I would like to work on this issue. Please assign it to me!

  3. DeepamJha commented on Aug 1, 2026

    @DeepamJha
    Contributor

    Hi @akramcodez, I'll be glad if u assign me this task as it's within my bandwidth right now, and I've worked in this codebase before (#729). Could you assign it to me?

  4. akramcodez commented on Aug 2, 2026

    @akramcodez
    MemberAuthor

    Hey @DeepamJha and @MsadafK, you both are already assigned to other issues. Could you please complete those first before taking on new ones? Thanks!

  5. DeepamJha commented on Aug 2, 2026

    @DeepamJha
    Contributor

    Yeah, both #729 and #736 are currently up waiting for review

  6. RealBhupesh commented on Aug 2, 2026

    @RealBhupesh
    Contributor

    I would like to work on this issue. I will include a focused fix and regression coverage in a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions