Repository navigation
Conversation
… column The regression-test sanitizer hardcoded index 3 as "Color" and overwrote it with "#0066CC". In the current six-column Categories layout (Name, Icon, Fields, Applies, Category ID, Icon ID) index 3 is the Applies column, so every sanitized category lost its observation/track value and generation failed with a track-coverage error. - Make sanitizeRowData header-aware: resolve columns by header label with canonical fallbacks, preserve Applies, set a deterministic Category ID, clear Icon ID, and only write a test color into an explicit Color column. Handles both the canonical layout and the import layout (Name, Icon, Fields, ID, Color, Icon ID), and scrubs numeric Category IDs. Also removes dead code surfaced while scoping #17: unused VALID_GEOMETRY_TYPES (validation.ts); processPresets.ts and its orphan testRow2Translation.ts (the v2 pipeline builds categories via builders/payloadBuilder.ts buildCategories); and corrects the stale CategoryRow column comment in types.ts. Adds testRegressionTesting.ts (Suite 15 / runTestSuite("regression")) and updates AGENTS.md + the test README. Verified: tsc --noEmit and biome clean; sanitizer logic unit-checked 15/15.
This was referenced Jul 22, 2026
luandro
force-pushed
the
chore/geometry-cleanup-and-regression-sanitizer-fix
branch
from
July 23, 2026 00:32
22caffe to
ee65598
Compare
- regressionTesting.ts sanitizeRowData: every other resolved column (nameCol, iconCol, categoryIdCol, iconIdCol) is guarded with `< sanitized.length` before array access, but fieldsCol wasn't. The out-of-bounds read was harmless (returns undefined, && short-circuits) but inconsistent, and would silently no-op instead of failing loudly if fieldsCol ever resolved past the row's actual width. - types.ts CategoryRow: the JSDoc documents [5] = Icon ID, but the interface stopped at [4], so row[5] fell back to the untyped string | number | boolean array element type with no autocomplete or narrowing. Reported by greptile CLI review of PR #51.
findCol (new in this PR) used Array.findIndex, resolving to the FIRST matching header on a sheet with duplicate column names. The codebase's other column-resolution helper, getCol (three instances in payloadBuilder.ts), builds a headerMap via forEach where a later duplicate key overwrites an earlier one — so it resolves to the LAST match instead. Scan the full header and keep the last match, matching getCol's behavior. Only matters on a degenerate sheet with duplicate column names (not exercised by the existing 10-case test suite, and nothing else in the codebase guards against duplicate headers either), so this is a consistency fix, not a functional bug fix. Flagged by pr-critical-reviewer as a non-blocking inconsistency during final PR readiness review. Implemented with mimo CLI (togetherai/Qwen3.7-Max), reviewed and verified (tsc, biome, manual diff read) before committing.
Contributor
Author
|
Closing as superseded: the sanitizer bug this PR fixes (Applies column clobbered by the regression-test color) is fixed on main by the #61 canonical-layout work (06799ca) plus the header-guarded sanitizer from the post-merge review (297fe40). This PR's header-aware column resolution would now conflict with the merged index-based fix. Valuable analysis — the header-aware idea informed the review. Follow-up for its author: run the regression suite inside Apps Script. |
luandro
added a commit
that referenced
this pull request
Oct 19, 2026
…, keep Color (#61) Import now writes the same Categories layout generate reads: Name | Icon | Fields | Applies | Category ID | Color | Icon ID. - Add CATEGORY_HEADERS single-source constant in src/constants/columns.ts; CATEGORY_COL gains COLOR (5), ICON_ID moves 5 -> 6. - populateCategoriesSheet (.comapeocat import) writes appliesTo per category (default "track, observation" only when the config lacks the field, logged), Category ID at E, Color at F, Icon ID at G; keeps column-A backgrounds. - applyCategories (legacy mapeosettings import) writes the same canonical header and per-preset appliesTo/id/color/iconId values. - apiService: EXPECTED_HEADERS.CATEGORIES, the legacy-A1 header rewrite, and validateCategoriesHeaderLayout now derive from CATEGORY_HEADERS (getter avoids GAS alphabetical load-order boot failure). - lint: validateCategoryIcons resolves the Icon ID column by header; new Task 7 rule flags old import layout (ID/Color at D/E, no Applies). - regressionTesting sanitizer and CategoryRow doc comment match canonical columns (fixes stale index-3-as-Color assumption, see #51). - Tests: new src/scripts/check-import-layout.cjs (npm run test:import-layout) covers both import writers, generate->import->generate round trip with byte-identical appliesTo + color, and layout validation; new testCanonicalCategoriesLayoutRoundTrip in src/test/testBuildAndImport.ts. gasSimHarness FakeSheet gains background/color + autoResizeColumns support. - Docs: categories-sheet reference/how-to and linting-rules updated. Closes #52. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where the regression-test sanitizer corrupted the Categories sheet's Applies column, plus removes dead code surfaced while scoping #17.
The bug
sanitizeRowData(src/regressionTesting.ts) hardcoded index 3 as "Color" and overwrote it with#0066CC. In the current six-column Categories layout (Name, Icon, Fields, Applies, Category ID, Icon ID) index 3 is the Applies column, so every sanitized category lost itsobservation/trackvalue. The builder silently coerced the invalid value to["observation"], no category retainedtrack, and generation failed with the track-coverage error.The fix
sanitizeRowDatais now header-aware: it resolves columns by header label (with canonical fallbacks), preserves Applies, sets a deterministictest-category-NCategory ID, clears Icon ID, and only writes a test color into an explicit Color column.Name, Icon, Fields, ID, Color, Icon IDfromimportService.ts), and scrubs numeric Category IDs (not just strings).Dead code removed (from #17 scoping)
VALID_GEOMETRY_TYPES(src/validation.ts) — zero references.src/generateConfig/processPresets.ts+ its orphansrc/test/testRow2Translation.ts— the v2 pipeline builds categories viabuilders/payloadBuilder.ts(buildCategories);processPresetswas only referenced by that one unregistered test.CategoryRowcolumn comment in src/types.ts (claimed[3]=Color / [4]=Geometry).Test
Adds
testRegressionTesting.ts(10 cases), registered as Suite 15 andrunTestSuite("regression"). Updates the test README and AGENTS.md pipeline note.Verification
bunx tsc --noEmit— cleanbunx biome check— cleanScope
Only the files for this change are included. Unrelated in-progress edits (
payloadBuilder.ts,utils.ts,version.ts,lint/*,testUtilsSlugify.ts) are not part of this PR.Remaining (needs Apps Script environment)
Push to the test project and run
runAllTests()/runTestSuite("regression"), do a manual regression-copy from a canonical 6-column sheet, and round-trip a generated.comapeocat.Greptile Summary
This PR fixes the regression spreadsheet sanitizer and removes unused legacy preset code. The main changes are:
Applies.Category ID,Icon ID, icon URLs, and explicitColorcolumns.runTestSuite("regression").processPresets,testRow2Translation, andVALID_GEOMETRY_TYPES.Confidence Score: 5/5
Safe to merge; no blocking issues found.
The sanitizer change is narrow and matches the current builder and import layouts. Tests cover the original
Appliescorruption case plus reordered headers, legacy color layout, import layout, and numeric IDs. Removed code was tied to an orphan legacy test path.No files require special attention.
What T-Rex did
Important Files Changed
Applies, scrubs category/icon IDs, and only changes explicit color columns.runAllTestsandrunTestSuite("regression").Sequence Diagram
Reviews (6): Last reviewed commit: "fix: make findCol resolve duplicate head..." | Re-trigger Greptile