Skip to content

Translate freecadweb to freecad in macro icon path#336

Merged
chennes merged 1 commit intoFreeCAD:devfrom
chennes:freecadwebConversion
Feb 9, 2026
Merged

Translate freecadweb to freecad in macro icon path#336
chennes merged 1 commit intoFreeCAD:devfrom
chennes:freecadwebConversion

Conversation

@chennes
Copy link
Member

@chennes chennes commented Feb 9, 2026

Prevent SSL errors when downloading the icons (also add code to gracefully catch this sort of error and just press on with the other macros).

Copilot AI review requested due to automatic review settings February 9, 2026 02:16
@chennes chennes merged commit 0cba75d into FreeCAD:dev Feb 9, 2026
15 checks passed
@chennes chennes added the release to main Trigger an Action to create a PR backporting to `main` label Feb 9, 2026
@chennes chennes deleted the freecadwebConversion branch February 9, 2026 02:18
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Successfully created backport PR for main:

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the server-side macro cache generation script to avoid SSL-related failures when downloading macro icons, and to keep processing remaining macros when an icon retrieval step fails.

Changes:

  • Wrap get_icon() calls during fetch_macros() to continue processing when a RuntimeError occurs, recording the error per macro.
  • Translate freecadwebfreecad in HTTP(S) macro icon URLs prior to download.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 172 to 175
if macro.icon.startswith("http://") or macro.icon.startswith("https://"):
if "freecadweb" in macro.icon:
macro.icon = macro.icon.replace("freecadweb", "freecad")
parsed_url = urllib.parse.urlparse(macro.icon)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

These changes introduce new behaviors that aren’t covered by the existing TestMacroCatalog suite (1) continuing fetch_macros() when get_icon() raises, and (2) translating freecadwebfreecad in icon URLs. Adding a unit test that mocks requests.get / MacroCatalog.get_icon would help prevent regressions (e.g., ensuring other macros still get processed and the translated URL is requested).

Copilot uses AI. Check for mistakes.
try:
self.get_icon(macro)
except RuntimeError as e:
self.macro_errors[macro.name] = str(e)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The new RuntimeError handler can overwrite a more specific existing entry for this macro in self.macro_errors (e.g., if get_icon already recorded a message before raising). Consider only setting this key when it’s not already present, or preserving/combining the existing message so the root cause isn’t lost.

Suggested change
self.macro_errors[macro.name] = str(e)
new_msg = str(e)
existing_msg = self.macro_errors.get(macro.name)
if existing_msg is None:
self.macro_errors[macro.name] = new_msg
elif new_msg and new_msg not in existing_msg:
self.macro_errors[macro.name] = f"{existing_msg} | {new_msg}"

Copilot uses AI. Check for mistakes.
try:
self.get_icon(macro)
except RuntimeError as e:
self.macro_errors[macro.name] = str(e)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

If get_icon raises, this handler records an error but leaves macro.icon/macro.icon_data in whatever partial state they were in at the time of the exception. To keep the cache consistent with the other error paths in get_icon (which clear macro.icon on failure), consider resetting the macro’s icon fields here as well.

Suggested change
self.macro_errors[macro.name] = str(e)
self.macro_errors[macro.name] = str(e)
# Ensure macro icon fields are consistent with other error paths in get_icon
macro.icon = None
macro.icon_data = None

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release to main Trigger an Action to create a PR backporting to `main`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant