dosubot[bot] commented on issue #8687:
URL: 
https://github.com/apache/incubator-devlake/issues/8687#issuecomment-3764278584

   <!-- Answer -->
   This happens because skipCollectors and fullSync are defined in an embedded 
struct (TriggerSyncPolicy) within Blueprint, but the code doesn't use the 
mapstructure:"squash" tag. As a result, PATCH requests only update these fields 
if you nest them under triggerSyncPolicy in your JSON payload, like this:
   
   ```json
   {
     "triggerSyncPolicy": {
       "skipCollectors": false,
       "fullSync": true
     }
   }
   ```
   
   Sending skipCollectors and fullSync at the top level won't work due to how 
the backend decodes the request body. Other fields like skipOnFail work because 
they're not nested.
   
   To fix this in the code, add `mapstructure:"squash"` to the 
TriggerSyncPolicy struct. That way, skipCollectors and fullSync can be updated 
at the top level, just like skipOnFail. There are currently no docs, issues, or 
PRs that mention this bug or a workaround. The persistence logic is fine—it's 
just the decoding step that causes the problem. 
   
   References:  
   [Blueprint model and struct 
embedding](https://github.com/apache/incubator-devlake/blob/main/backend/core/models/blueprint.go)
  
   [PATCH handler and decoding 
logic](https://github.com/apache/incubator-devlake/blob/main/backend/server/services/blueprint.go)
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/cc1eebfe-8430-4e97-8482-43e9be93fa38?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/cc1eebfe-8430-4e97-8482-43e9be93fa38?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/cc1eebfe-8430-4e97-8482-43e9be93fa38?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/cc1eebfe-8430-4e97-8482-43e9be93fa38?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/cc1eebfe-8430-4e97-8482-43e9be93fa38?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/cc1eebfe-8430-4e97-8482-43e9be93fa38?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/cc1eebfe-8430-4e97-8482-43e9be93fa38?feedback_type=other)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/b4e8e847-d479-4541-83a8-d88d83fea5c9/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20happens%20because%20skipCollectors%20and%20fullSync%20are%20defined%20in%20an%20embedded%20struct%20%28TriggerSyncPolicy%29%20within%20Blueprint%2C%20but%20the%20code%20doesn%27t%20use%20the%20mapstructure%3A%22squash%22%20tag.%20As%20a%20result%2C%20PATCH%20requests%20only%20update%20these%20fields%20if%20you%20nest%20them%20under%20triggerSyncPolicy%20in%20your%20JSON%20payload%2C%20like%20this%3A%0A%0A%60%60%60json%0A%7B%0A%20%20%22triggerSyncPolicy%22%3A%20%7B%0A%20%20%20%20%22skipCollectors%22%3A%20false%2C%0A%20%20%20%20%22fullSync%22%3A%20true%0A%20%20%7D%0A%7D%0A%60%60%60%0A%0ASending%20skipCollectors%20and%20fullSync%20at%20the%20top%20level%20won%27t%20work%20due%20to%20how%20the%20backend%20decodes%20the%20request%20body.%20Other%
 
20fields%20like%20skipOnFail%20work%20because%20they%27re%20not%20nested.%0A%0ATo%20fix%20this%20in%20the%20code%2C%20add%20%60mapstructure%3A%22squash%22%60%20to%20the%20TriggerSyncPolicy%20struct.%20That%20way%2C%20skipCollectors%20and%20fullSync%20can%20be%20updated%20at%20the%20top%20level%2C%20just%20like%20skipOnFail.%20There%20are%20currently%20no%20docs%2C%20issues%2C%20or%20PRs%20that%20mention%20this%20bug%20or%20a%20workaround.%20The%20persistence%20logic%20is%20fine%E2%80%94it%27s%20just%20the%20decoding%20step%20that%20causes%20the%20problem.%20%0A%0AReferences%3A%20%20%0A%5BBlueprint%20model%20and%20struct%20embedding%5D%28https%3A//github.com/apache/incubator-devlake/blob/main/backend/core/models/blueprint.go%29%20%20%0A%5BPATCH%20handler%20and%20decoding%20logic%5D%28https%3A//github.com/apache/incubator-devlake/blob/main/backend/server/services/blueprint.go%29)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https
 ://go.dosu.dev/discord-bot)&nbsp;[![Share on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-devlake/issues/8687)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to