Skip to content

fix: persist site config via setConfig after disableImport#240

Merged
prithipalpatwal merged 2 commits into
mainfrom
fix/disable-import-audit-set-config
Apr 1, 2026
Merged

fix: persist site config via setConfig after disableImport#240
prithipalpatwal merged 2 commits into
mainfrom
fix/disable-import-audit-set-config

Conversation

@prithipalpatwal
Copy link
Copy Markdown
Contributor

Site save tracks updates through setters; mutating getConfig() alone did not reliably persist import changes. Calling setConfig(Config.toDynamoItem(siteConfig)) before save.

Tests mock Config.toDynamoItem and assert setConfig on success paths, and that setConfig is skipped when the site is not found or lookup fails.

Made-with: Cursor

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

Related Issues

Thanks for contributing!

…sableImport

Site save tracks updates through setters; mutating getConfig() alone did not
reliably persist import changes. Mirror brand-profile by calling
setConfig(Config.toDynamoItem(siteConfig)) before save.

Tests mock Config.toDynamoItem and assert setConfig on success paths, and that
setConfig is skipped when the site is not found or lookup fails.

Made-with: Cursor
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tkotthakota-adobe
Copy link
Copy Markdown
Collaborator

Hi @prithipalpatwal

 Assessment                                                              
   
  The fix is correct. This is a real bug — Config is a wrapper object, not
   a plain reference to site.state.config. Mutating it doesn't
  automatically mark the site as dirty. Config.toDynamoItem() serializes  
  it back to the raw format that setConfig expects.         

  One concern — import path:                                              
   
  import { Config } from                                                  
  '@adobe/spacecat-shared-data-access/src/models/site/config.js';         
                                                                          
  This imports directly from an internal src/ path of the published       
  package, not from its public entry point. This is fragile — internal
  paths can change without a semver bump. It works now but could break on 
  a lib update.                                             

  Ideally Config and toDynamoItem should be exported from the package's   
  public index.js. Worth checking if there's an alternative export, or
  raising it with the shared-data-access team to expose toDynamoItem      
  publicly.                                                 

  Tests are thorough — every code path (success, errors, edge cases)      
  asserts both toDynamoItemStub and setConfig were called correctly. The
  negative cases (errors before setConfig is reached) correctly assert    
  setConfig was not called.                                 

  Overall: good to merge, with the internal import path being a minor     
  concern to track.
                    

*/

import { ok } from '@adobe/spacecat-shared-http-utils';
import { Config } from '@adobe/spacecat-shared-data-access/src/models/site/config.js';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This imports directly from an internal src/ path of the published
package, not from its public entry point. This is fragile — internal
paths can change without a semver bump. It works now but could break on
a lib update.

Ideally Config and toDynamoItem should be exported from the package's
public index.js. Worth checking if there's an alternative export, or
raising it with the shared-data-access team to expose toDynamoItem
publicly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR, will merge it tomorrow. Thanks!

Use the package root instead of an internal src/models path so semver
covers export stability. Align esmock with the new import specifier.

Made-with: Cursor
@github-actions
Copy link
Copy Markdown

This PR will trigger a patch release when merged.

@prithipalpatwal prithipalpatwal merged commit 39b9e0a into main Apr 1, 2026
28 checks passed
@prithipalpatwal prithipalpatwal deleted the fix/disable-import-audit-set-config branch April 1, 2026 07:18
solaris007 pushed a commit that referenced this pull request Apr 1, 2026
## [1.12.19](v1.12.18...v1.12.19) (2026-04-01)

### Bug Fixes

* persist site config via setConfig after disableImport ([#240](#240)) ([39b9e0a](39b9e0a))
@solaris007
Copy link
Copy Markdown
Member

🎉 This PR is included in version 1.12.19 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants