Make getAiDisclosureSettings survive blocked localStorage, and add tests
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 94/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- next.js, typescript
- Domain
- frontend
Research direction
Start with frontend/src/lib/ai-disclosure.ts, comparing the unguarded reads in getAiDisclosureSettings with the guarded writes in saveAiDisclosureSettings and the existing SSR defaults. Add frontend/src/lib/ai-disclosure.test.ts with // @vitest-environment jsdom, then run cd frontend && npx vitest run src/lib/ai-disclosure.test.ts. The change is done when blocked storage returns DEFAULT_AI_DISCLOSURE without throwing, all listed fallback cases pass, and a changelog fragment is added under changelog.d/.
Written by the indexing model from the issue text.
Description
What is wrong / what to do
saveAiDisclosureSettings wraps its localStorage writes in try/catch, but getAiDisclosureSettings reads localStorage with no guard. When storage is blocked (some private modes, sandboxed iframes, or blocked site data), reading window.localStorage throws a SecurityError. That error goes through getAiDisclosure(), which both export paths call when they build provenance metadata, so the whole export fails. Wrap the reads so that a throw falls back to the same defaults the SSR branch already returns (voice_script, empty custom text, enabled), as the comment at line 83 says it should. Add ai-disclosure.test.ts to cover this.
Where in the code
frontend/src/lib/ai-disclosure.ts:64-73— unguardedlocalStorage.getItemat lines 68, 70, 71frontend/src/lib/ai-disclosure.ts:76-85— the write path, which is guardedfrontend/src/lib/ai-disclosure.ts:91-99—getAiDisclosurefrontend/src/engine/render-pipeline.ts:350and:692,frontend/src/engine/cartoon/cartoon-renderer.ts:215— export-time callers
How to reproduce, or the test command
# put `// @vitest-environment jsdom` on the first line of the test file
cd frontend && npx vitest run src/lib/ai-disclosure.test.ts
Repro in a test: Object.defineProperty(window, 'localStorage', { get() { throw new DOMException('denied', 'SecurityError') }, configurable: true }), then call getAiDisclosure(). Today it throws SecurityError: denied.
Done when
- With a throwing
localStorage,getAiDisclosure()returnsDEFAULT_AI_DISCLOSUREand does not throw - Tests cover: nothing stored returns
DEFAULT_AI_DISCLOSURE;enabled = 'false'returns''; presetcustomwith blank text falls back to the default; presetcustomwith text returns the trimmed text; an unknown stored preset id falls back tovoice_script - Tests added or updated, and the command above passes
- Changelog fragment in
changelog.d/
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 3
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from BeyondITL/contentine-create
-
good first issue level: 1 ui
Difficulty 2/5 1-3 hours Newbie friendliness 94/100
BeyondITL/contentine-create#58 ·
Maintainers usually reply within 1 day
-
Fix Enter on the marketplace Buy button opening details instead of buyingPossibly taken @developedbyBob claimed this 3 days ago. Openaccessibility claimed good first issue level: 1
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
BeyondITL/contentine-create#57 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Enable JSX in vitest so React component tests can runPossibly taken @29miaoet claimed this 4 days ago. Openclaimed good first issue level: 1 testing
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
BeyondITL/contentine-create#56 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
good first issue level: 1 testing
Difficulty 2/5 1-3 hours Newbie friendliness 94/100
BeyondITL/contentine-create#55 ·
Maintainers usually reply within 1 day
-
good first issue level: 1 testing
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
BeyondITL/contentine-create#54 ·
Maintainers usually reply within 1 day
All issues in BeyondITL/contentine-create
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
paperclipai/paperclip#19120 ·
Maintainers usually reply within 1 day
-
Gradle liquibaseDiffChangelog drops jhi_date_time_wrapperPossibly taken @mraible claimed this today. Openarea: triage theme: undefined
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
jhipster/generator-jhipster#35998 ·
Maintainers usually reply within 1 day
-
ai:assign:coding feature p3 ui-ux windows
Difficulty 1/5 Under an hour Newbie friendliness 82/100
CherryHQ/cherry-studio#23569 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 78/100
lingdojo/kana-dojo#33602 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
GoogleCloudPlatform/BigQuery-Agent-Analytics-Plugins#16 ·
Maintainers usually reply within 1 day