Skip to content

[API Policies] Semantic Cache Policy Issue #696

@DakshithaS

Description

@DakshithaS

Overview

Cache isolation bug prevents cache hits when API identity information is missing, completely defeating the caching mechanism.


Issue Details

Fallback to RequestID Causes Cache Isolation Per Request

File: semanticcache.go (lines 429-434)

Description:
When apiID is ":" (indicating missing API name/version), the code falls back to using ctx.RequestID as the cache key. Since RequestID is unique per request, this prevents any cache sharing across requests - each response gets cached under a different key and can never be retrieved.

Code Flow:

apiID := fmt.Sprintf("%s:%s", ctx.APIName, ctx.APIVersion)
if apiID == ":" {
    apiID = ctx.RequestID // PROBLEM: Unique per request!
}

Proposed Fix:
Use a meaningful fallback for apiID instead of RequestID, such as a default value or log a warning about missing apiID.

Impact:
Cache hits will never occur when apiID is ":", completely defeating the purpose of semantic caching.

Reference

Metadata

Metadata

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