fix(backend): don't mislabel fresh lockdown-gate cache hits as stale #23

Merged
starkSV merged 1 commit from fix/lockdown-cache-status into main 2026-07-08 19:48:19 +05:30
starkSV commented 2026-07-08 19:48:05 +05:30 (Migrated from github.com)

Summary

  • backend/main.go: the Sentinel lockdown gate labeled any linkCache hit as stale regardless of whether the entry was still within its own TTL
  • A link just contributed via CLI (still valid for ~24h) would get labeled stale, causing the frontend to hide it and show the CLI-only banner again instead of the working link it just received
  • Now checks the entry's actual expiry: still-fresh entries are labeled cached (frontend shows the link normally); only genuinely expired entries are labeled stale

Test plan

  • Backend builds clean
  • Merge and redeploy backend via Coolify
  • Confirm: trigger a lockdown, contribute a fresh link via CLI, reload web -- link should now display instead of CLI-only banner

Summary by CodeRabbit

  • Bug Fixes
    • Improved link serving behavior during lockdown so recently cached entries are now labeled and counted as cached instead of stale.
    • Expired entries continue to be served as stale, with clearer status reporting in responses and logs.
## Summary - backend/main.go: the Sentinel lockdown gate labeled any linkCache hit as stale regardless of whether the entry was still within its own TTL - A link just contributed via CLI (still valid for ~24h) would get labeled stale, causing the frontend to hide it and show the CLI-only banner again instead of the working link it just received - Now checks the entry's actual expiry: still-fresh entries are labeled cached (frontend shows the link normally); only genuinely expired entries are labeled stale ## Test plan - Backend builds clean - Merge and redeploy backend via Coolify - Confirm: trigger a lockdown, contribute a fresh link via CLI, reload web -- link should now display instead of CLI-only banner <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved link serving behavior during lockdown so recently cached entries are now labeled and counted as cached instead of stale. * Expired entries continue to be served as stale, with clearer status reporting in responses and logs. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
coderabbitai[bot] commented 2026-07-08 19:49:38 +05:30 (Migrated from github.com)

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3d5ceedf-7bd3-44aa-9d35-d0b58ff7b223

📥 Commits

Reviewing files that changed from the base of the PR and between e5d9dc3d61 and 8b430fab5d.

📒 Files selected for processing (1)
  • backend/main.go

📝 Walkthrough

Walkthrough

The Sentinel lockdown handling in backend/main.go's handleProxy function now checks whether a cached staleEntry is still within its TTL. If within TTL, it's served as cached with corresponding metrics and headers; otherwise it's served as stale, replacing the prior unconditional stale treatment.

Changes

Sentinel lockdown cache status fix

Layer / File(s) Summary
TTL-aware cached vs stale handling
backend/main.go
Checks staleEntry.ExpiresAt in the lockdown branch to serve entries as cached (mLinkCacheHits, X-MSDL-Link-Status: cached) when still within TTL, or as stale (mLinkStale, X-MSDL-Link-Status: stale) otherwise.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lockdown-cache-status

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/starkSV/windows-iso-downloader/pull/23?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: failure by coderabbit.ai --> > [!CAUTION] > ## Review failed > > The pull request is closed. <!-- end of auto-generated comment: failure by coderabbit.ai --> <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro Plus **Run ID**: `3d5ceedf-7bd3-44aa-9d35-d0b58ff7b223` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between e5d9dc3d613c7f021bada327d19d531096a9ecb6 and 8b430fab5dc12fc57e4552ffb19930350b14e0e1. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `backend/main.go` </details> </details> --- <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The Sentinel lockdown handling in backend/main.go's handleProxy function now checks whether a cached staleEntry is still within its TTL. If within TTL, it's served as cached with corresponding metrics and headers; otherwise it's served as stale, replacing the prior unconditional stale treatment. ### Changes **Sentinel lockdown cache status fix** |Layer / File(s)|Summary| |---|---| |**TTL-aware cached vs stale handling** <br> `backend/main.go`|Checks `staleEntry.ExpiresAt` in the lockdown branch to serve entries as cached (`mLinkCacheHits`, `X-MSDL-Link-Status: cached`) when still within TTL, or as stale (`mLinkStale`, `X-MSDL-Link-Status: stale`) otherwise.| **Estimated code review effort:** 1 (Trivial) | ~5 minutes </details> <!-- walkthrough_end --> <!-- finishing_touch_checkbox_start --> <details> <summary>✨ Finishing Touches</summary> <details> <summary>📝 Generate docstrings</summary> - [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> Create stacked PR - [ ] <!-- {"checkboxId": "3e1879ae-f29b-4d0d-8e06-d12b7ba33d98"} --> Commit on current branch </details> <details> <summary>🧪 Generate unit tests (beta)</summary> - [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests - [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit unit tests in branch `fix/lockdown-cache-status` </details> </details> <!-- finishing_touch_checkbox_end --> <!-- This is an auto-generated comment: all tool run failures by coderabbit.ai --> > [!WARNING] > There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. > > <details> > <summary>🔧 golangci-lint (2.12.2)</summary> > > level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" > > > > > </details> <!-- end of auto-generated comment: all tool run failures by coderabbit.ai --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=starkSV/windows-iso-downloader&utm_content=23)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: shekhar/windows-iso-downloader#23
No description provided.