GSA / GSA/touchpoints

Evaluate whether some DB migrations need to invalidate FormCache

Open
#2,093 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
67
Forks
37
Avg merge
2d 12h
Merged PRs (30d)
5

Description

Touchpoints caches Form model objects to improve performance. The code invalidates a cached form whenever the Rails code updates the value of its fields in the underlying db representation. But there is nothing in place to invalidate the cache in response to database migrations. We should put something in place.

### Example demonstrating why this matters
A [recent PR](https://github.com/GSA/touchpoints/pull/2081) added a `logo_alt_text` column to the `forms` table. After deploying this to production, we started seeing 500 errors reported in the log for the `GET /touchpoints/{uuid}/submit` endpoint. Here's an AI-generated recap of the issue:

- **Symptom:** ActiveModel::MissingAttributeError (missing attribute 'logo_alt_text' for Form) on GET /touchpoints/{id}/submit.
- **Root cause:** Stale Form objects cached in Redis (FormCache, 1-day TTL) from before the logo_alt_text migration ran. The DB was correct; the serialized cached objects had no logo_alt_text key, so reading it via Form#logo_alt_text_or_default raised the error without hitting the DB.
- **Fix applied:** surgically deleted the namespace:form-* keys from Redis via redis-cli --scan | xargs UNLINK.

The endpoint in question loads a hosted form for a user who wants to fill out the form. As long as these errors were occurring, users were not able to submit feedback through the forms in question and they were seeing an ugly error page when they tried to. There were over 100 forms in the cache - combined with a 1-day TTL, this could have been a serious glitch.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing FormCache invalidation and the GET /touchpoints/{uuid}/submit path, then review how database migrations are deployed and how cached Form objects are serialized in Redis. Done means migrations that can change Form attributes no longer leave stale cached objects capable of causing MissingAttributeError, with the behavior verified against the reported stale-cache scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, redis
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.