Fix occasional assembly mislogging - #1696
Conversation
5163a95 to
8751485
Compare
8751485 to
f24b68d
Compare
Greptile SummaryThis PR changes direct heartbeat normalization so unrecognised client-provided language names fall back to entity-based detection and adds service-level regression coverage.
Confidence Score: 4/5The PR should not merge until resolved last-language placeholders are protected from being replaced using the current entity's extension. The new recognition gate runs after placeholder resolution, so an unrecognised historical language can be replaced with an unrelated extension-derived language and alter both stored metadata and deduplication identity; the added preservation test also cannot detect unconditional fallback. Files Needing Attention: app/services/heartbeat_ingest.rb, test/services/heartbeat_ingest_test.rb Important Files Changed
Prompt To Fix All With AI### Issue 1
app/services/heartbeat_ingest.rb:107-108
**Placeholder language gets overwritten**
When `<<LAST_LANGUAGE>>` resolves to an unrecognised historical value, this check discards that value and infers a language from the current entity instead. For example, after an `RGBDS Assembly` heartbeat, a `.py` heartbeat using the placeholder is stored as Python rather than the requested last language. This also changes the heartbeat identity used for deduplication.
### Issue 2
test/services/heartbeat_ingest_test.rb:839-840
**Preservation test cannot distinguish fallback**
This test uses `language: "Assembly"` with an `.asm` entity, so it still passes if the implementation discards the recognised client language and falls back to extension detection. Use a recognised language that differs from the extension-derived language so the test actually verifies preservation.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "Fall back to extension detection for unr..." | Re-trigger Greptile |
| known_language = attrs[:language] if LanguageUtils.find_name(attrs[:language]) | ||
| inferred = LanguageUtils.fill_missing_language(known_language, entity: attrs[:entity]) |
There was a problem hiding this comment.
Placeholder language gets overwritten
When <<LAST_LANGUAGE>> resolves to an unrecognised historical value, this check discards that value and infers a language from the current entity instead. For example, after an RGBDS Assembly heartbeat, a .py heartbeat using the placeholder is stored as Python rather than the requested last language. This also changes the heartbeat identity used for deduplication.
Knowledge Base Used: Heartbeat tracking and ingestion
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/services/heartbeat_ingest.rb
Line: 107-108
Comment:
**Placeholder language gets overwritten**
When `<<LAST_LANGUAGE>>` resolves to an unrecognised historical value, this check discards that value and infers a language from the current entity instead. For example, after an `RGBDS Assembly` heartbeat, a `.py` heartbeat using the placeholder is stored as Python rather than the requested last language. This also changes the heartbeat identity used for deduplication.
**Knowledge Base Used:** [Heartbeat tracking and ingestion](https://app.greptile.com/mahadk/-/custom-context/knowledge-base/hackclub/hackatime/-/docs/heartbeat-tracking.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| entity: "src/main.asm", | ||
| language: "Assembly", |
There was a problem hiding this comment.
Preservation test cannot distinguish fallback
This test uses language: "Assembly" with an .asm entity, so it still passes if the implementation discards the recognised client language and falls back to extension detection. Use a recognised language that differs from the extension-derived language so the test actually verifies preservation.
Prompt To Fix With AI
This is a comment left during a code review.
Path: test/services/heartbeat_ingest_test.rb
Line: 839-840
Comment:
**Preservation test cannot distinguish fallback**
This test uses `language: "Assembly"` with an `.asm` entity, so it still passes if the implementation discards the recognised client language and falls back to extension detection. Use a recognised language that differs from the extension-derived language so the test actually verifies preservation.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary of the problem
Editors like Zed Sometimes send "RGBDS Assembly" as the language for
.asmfiles. Since that string isn't inlanguages.ymlorlanguges_custom.yml, it was stored as is, instead of mapping to Assembly.Describe your changes
Previously,
normalize_direct_heartbeatonly fell back to extension detection when the client language was blank or unknown. Now it also falls back whenever the client language isn't recognized.Comes with 2 tests to verify unrecognized client languages are replaced using extension detection and one to verify recognized languages are still preserved.
Screenshots / Media
N/A