Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(override-base-url): add overrideBaseURL in site.config.fetchConfig #633

Merged
merged 9 commits into from
Feb 28, 2025

Conversation

iuliag
Copy link
Contributor

@iuliag iuliag commented Feb 26, 2025

Implements: https://jira.corp.adobe.com/browse/SITES-29423

Additionally, adds as optional the other properties in the different types of import config.

@iuliag iuliag added the enhancement New feature or request label Feb 26, 2025
@iuliag iuliag self-assigned this Feb 26, 2025
@@ -85,6 +86,7 @@ export const configSchema = Joi.object({
),
fetchConfig: Joi.object({
headers: Joi.object().pattern(Joi.string(), Joi.string()),
overrideBaseURL: Joi.string().uri(),
Copy link
Contributor

Choose a reason for hiding this comment

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

will this also work for import config or should we've a separate config for imports?

Copy link
Contributor Author

@iuliag iuliag Feb 27, 2025

Choose a reason for hiding this comment

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

I'm going to open a PR https://github.com/adobe/spacecat-import-worker/pull/265 in the import-worker to use the new override provided at site.config.fetchConfig level

Copy link
Contributor

Choose a reason for hiding this comment

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

thank you. So, there'll be separate PR for broken-backlinks audit to leverage the overrideUrl right? the url introduced in https://jira.corp.adobe.com/browse/SITES-29345 isn't required any more right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'm updating all the repos (see PR list in https://jira.corp.adobe.com/browse/SITES-29423?focusedId=46432145&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-46432145), while I figure out why nock doesn't work as expected in the unit tests here.

Copy link

This PR will trigger a patch release when merged.

@iuliag iuliag marked this pull request as ready for review February 27, 2025 11:17
@ekremney
Copy link
Member

overrideBaseURL in SITES-29423 is a great idea. However implementing a resolveFinalURL method which does all the redirect following logic intertwined with overrideBaseURL might create confusion.

I see two shortcomings of resolveFinalURL method:

  1. http calls are error prone (ie bot detection) won't work all the time
  2. resolveFinalURL logic is different for all consumers (imports audits etc)

hence, I suggest to use overrideBaseURL field with getBaseURL method (with a useOverride param which is false by default) and let the url resolving to consumers. Examples:

no overrideBaseURL set:

baseURL: https://spacecat.com
overrideBaseURL: null

getBaseURL() => https://spacecat.com
getBaseURL(useOverride=true) => https://spacecat.com

overrideBaseURL set:

baseURL: https://spacecat.com
overrideBaseURL: https://spacedog.com

getBaseURL() => https://spacecat.com
getBaseURL(useOverride=true) => https://spacedog.com

whatever the consumer downstream (import, audit etc) can decide which one to use @iuliag

@solaris007
Copy link
Member

@ekremney not sure i can support the proposal. while I understand where you're coming from, the getBaseURL has almost ID character and i see cases where developers have overrideBaseURL=>true set but later treat the baseURL as before. Also, if possible, auto-generated accessors should not be overridden. It may also lead to the temptation to use setBaseURL for "override" URLs.

@ekremney
Copy link
Member

Also, if possible, auto-generated accessors should not be overridden.

@solaris007 got it, similar fashion a getBaseURLOverride() would do the job as well. Then the consumer would have to check if there is an manual override set.

@rpapani
Copy link
Contributor

rpapani commented Feb 28, 2025

Then the consumer would have to check if there is an manual override set.

Rather than each consumer handling base or override, it'll be great, if the resolveUrl takes care of this.

@iuliag iuliag merged commit 526874f into main Feb 28, 2025
7 checks passed
@iuliag iuliag deleted the override-base-url branch February 28, 2025 13:25
solaris007 pushed a commit that referenced this pull request Feb 28, 2025
# [@adobe/spacecat-shared-data-access-v2.9.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.9.4...@adobe/spacecat-shared-data-access-v2.9.5) (2025-02-28)

### Bug Fixes

* **override-base-url:** add overrideBaseURL in site.config.fetchConfig ([#633](#633)) ([526874f](526874f))
@solaris007
Copy link
Member

🎉 This PR is included in version @adobe/spacecat-shared-data-access-v2.9.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

iuliag added a commit to adobe/spacecat-audit-worker that referenced this pull request Feb 28, 2025
solaris007 pushed a commit to adobe/spacecat-audit-worker that referenced this pull request Feb 28, 2025
## [1.62.3](v1.62.2...v1.62.3) (2025-02-28)

### Bug Fixes

* **override-base-url:** use overrideBaseURL from site.config.fetchConfig ([#719](#719)) ([3149d47](3149d47)), closes [adobe/spacecat-shared#633](adobe/spacecat-shared#633)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants