bug: deal_sid and function_title fields silently lost on every save round-trip #44
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_biz#44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two fields added to their respective models are not mapped when constructing the OSIS structs for save, so they are silently dropped on every write:
Task.deal_siddeal_sidwas added toTaskRecordin commit764d90d, butservices/mod.rsinitializesdeal_sid: Nonewhen loading and theh0_taskconstruction on save does not include adeal_sidmapping. Every call tosave_taskpermanently erases thedeal_sidvalue.Person.function_titleSimilarly,
function_title: Option<String>was added toPersonRecordbut is always initialized toNoneon load and is not included in theh0_personconstruction on save.Impact
Any task with a linked deal will have that link silently cleared on the next save. This is a data-loss bug that is not visible to the user.
Fix
Map both fields in the OSIS struct construction in
services/mod.rs:And ensure both are read back when loading from OSIS.
Affected code
crates/hero_biz_ui/src/services/mod.rs—save_task,save_person, and their OSIS load pathsFound in
PR #21 review
Implementation Spec for Issue #44
Objective
Fix two data-loss bugs in
crates/hero_biz_ui/src/services/mod.rswhereTask.deal_sidandPerson.function_titleare silently discarded on every save round-trip because they are not mapped to or from the OSIS backend structs.Root Cause
Neither
deal_sidonhero_osis_sdk::projects::Tasknorfunction_titleonhero_osis_sdk::business::Personexist as OSIS schema fields — the storage layer has no column for them. Both fields are application-level extensions that require a storage strategy.The existing codebase already solves this for HR fields (
job_title:,department:,start_date:,salary:) using a prefixed-tag convention onPerson.tags. This same pattern must be applied to both fields.Requirements
deal_sidmust survive a fullsave_task+load_taskround-trip.function_titlemust survive a fullsave_person+load_personround-trip.tagsprefixed-key pattern:"deal_sid:<value>"and"function_title:<value>".Noneor empty.tagsfield on load.services/mod.rs.Files to Modify
crates/hero_biz_ui/src/services/mod.rs—load_task,save_task,load_person,save_personImplementation Plan
Step 1 — Fix
save_task: encodedeal_sidinto tagsIn
save_task, replacetags: task.tags.clone()with:Step 2 — Fix
load_task: decodedeal_sidfrom tagsIn
load_task, replacedeal_sid: Nonewith:And strip the internal tag from the user-visible
tagsfield:Step 3 — Fix
save_person: encodefunction_titleinto tagsIn
save_person, replacetags: person.tags.clone()with:Step 4 — Fix
load_person: decodefunction_titlefrom tagsIn
load_person, replacefunction_title: Nonewith:And strip the internal tag from the user-visible
tagsfield:Acceptance Criteria
save_taskwithdeal_sid: Some("abc123")followed byload_taskreturnsdeal_sid == Some("abc123")save_taskwithdeal_sid: Noneleaves nodeal_sid:entry in tagsload_tasknever returnsdeal_sid:...in the user-visibletagslistsave_personwithfunction_title: Some("Investor")followed byload_personreturnsfunction_title == Some("Investor")save_personwithfunction_title: Noneleaves nofunction_title:entry in tagsload_personnever returnsfunction_title:...in the user-visibletagslistcargo buildsucceeds with no new warnings or errorsNotes
hr_create/hr_updateencodejob_title:,department:,start_date:, andsalary:as prefixed tags onPerson. This fix is idiomatic.Noneon load. The values were already lost on the previous save (the reported bug). This fix prevents future data loss; it does not recover already-lost data.task_createandtask_updatehandlers currently setdeal_sid: None. Adding UI support for linking tasks to deals is out of scope and would require separate handler changes.Test Results
Status: Build failed — no tests were executed.
Compilation Errors
The build failed with 244 compiler errors across the
hero_biz_uiandhero_biz_appcrates. No test binaries were produced, so no tests ran.The errors fall into two categories:
1. Axum version conflict (
E0277— 208 errors)There are two incompatible versions of
axumin the dependency graph:axum 0.7.9andaxum 0.8.9. Handlers useCookieJarandaxum-extrafrom one version while the router expects traits from the other. Every handler registration fails with:Affected handlers include:
login_submit,logout,index,index_redirect,persons_list,person_new,person_create,persons_detail,person_edit,person_update,person_link_delete,companies_list,company_new,company_create,companies_detail,company_edit,company_update, and many more.2. Missing function
init_logger(E0425— 1 error)The function
init_loggeris referenced inserver.rsbut is not defined in theloggingmodule.3. Mismatched types (
E0308— 1 error)Related to the axum version mismatch.
Root Cause
The primary issue is that
hero_biz_uiimportsaxum-extra 0.9.6(which pairs withaxum 0.8.x) while another dependency pulls inaxum 0.7.9. TheCookieJarextractor andIntoResponsePartstrait are incompatible between these versions. Pinning all axum-family crates to a single version (either all 0.7.x or all 0.8.x) should resolve the bulk of errors.Test Results
Build: clean (
cargo buildsucceeded with 0 errors, 0 warnings).All 7 existing tests in
hero_biz_ui::services::testscontinue to pass.Implementation Summary
Changes Made
crates/hero_biz_ui/src/services/mod.rs— issue #44 fixsave_task: encodesdeal_sidas a prefixed tag (deal_sid:<value>) before writing to OSIS, filtering out any stale copy first.load_task: decodesdeal_sidfrom the tag prefix on load; strips the internal tag from the user-visibletagsfield.save_person: encodesfunction_titleas a prefixed tag (function_title:<value>) before writing to OSIS.load_person: decodesfunction_titlefrom the tag prefix on load; strips the internal tag from the user-visibletagsfield.Storage strategy: neither field exists in the OSIS schema. The fix uses the existing prefixed-tag convention already in place for HR fields (
job_title:,department:,start_date:,salary:).crates/hero_biz_ui/Cargo.toml— dependency fixaxumfrom0.8to0.7to resolve a version conflict withaxum-extra 0.9(which pairs with axum 0.7). The axum 0.8 bump in commita1c9bb3was not accompanied by the necessaryaxum-extraandaskama_axumupgrades, which broke the build with 120+ handler trait errors. A dedicated axum 0.8 upgrade (requiringaxum-extra 0.12+and an askama integration migration) is left for a separate issue.crates/hero_biz_ui/src/logging.rsandcrates/hero_biz/src/main.rs— build fixArc::new(logger)wrapping in both files.Logger::new()already returnsArc<Logger>; the extra wrap producedArc<Arc<Logger>>which failed to compile.crates/hero_biz_ui/src/web/server.rs— build fixcrate::logging::init_logger(...)(non-existent) tocrate::logging::init_hero_log("biz.admin")(the actual function name after the logging rewrite ina1c9bb3).Audit
A full audit of all
save_*andload_*functions inservices/mod.rsfound no other fields silently dropped on round-trip. The only structurally similar case (contact.user_sid: Noneinload_contact) is intentional — it is populated from link relationships at the handler layer immediately after loading.Test Results
cargo build: clean, no errors or warnings.Fixed in commit
6387be8on branchdevelopment_casper.Both
function_title(Person) anddeal_sid(Task) are now round-tripped via tagged fields in the OSIS persistence layer, following the existing tag-encoding pattern already in use for other HR extension fields. Data is no longer silently dropped on save.