~sthagen

Switzerland

https://stefan-hagen.website

Working with teams, changing things and the way we work. Any personal contribution of this user is MIT licensed. Opinions expressed on behalf of himself only.

Trackers

~sthagen/putki

Last active 3 hours ago

~sthagen/csaf

Last active 2 days ago

~sthagen/liitos

Last active 2 days ago

~sthagen/laskea

Last active 2 days ago

~sthagen/etiketti

Last active 8 days ago

~sthagen/nap

Last active 2 months ago

~sthagen/visailu

Last active 3 months ago

~sthagen/synkronoida

Last active 4 months ago

~sthagen/kutoa

Last active 5 months ago

~sthagen/asiakirjasuodatin

Last active 5 months ago
View more

#8 Fix noisy exceptions from naive key access in traversal (cf. line 148) 3 hours ago

~sthagen assigned ~sthagen to #8 on ~sthagen/putki

#8 Fix noisy exceptions from naive key access in traversal (cf. line 148) 3 hours ago

Bug added by ~sthagen on ~sthagen/putki

#8 Fix noisy exceptions from naive key access in traversal (cf. line 148) 3 hours ago

Ticket created by ~sthagen on ~sthagen/putki

https://git.sr.ht/~sthagen/putki/tree/default/item/putki/traverse.py#L148 spams the logs when target key not present:

2023-11-29T09:45:44.002787+00:00 INFO [PUTKI]: - com-pon-ent:
2023-11-29T09:45:44.003364+00:00 INFO [PUTKI]:   + design:
Traceback (most recent call last):

  File "putki", line 8, in 
    sys.exit(app())

  File "putki/cli.py", line 170, in verify_structures
    api.verify_structures(doc_root=doc, structures_name=structures, component=component, options=options)

  File "putki/api.py", line 42, in verify_structures
    code, message, root, claims = traverse.follow(structures_name)

  File "putki/traverse.py", line 148, in follow
    for facet in structure_info[target]:

KeyError: ' com-pon-ent_design'

Can we maybe either silence the exception or provide a concise useful information instead?

Proposal:

diff --git a/putki/traverse.py b/putki/traverse.py
index 9ddff46..ce8c344 100644
--- a/putki/traverse.py
+++ b/putki/traverse.py
@@ -145,8 +145,12 @@ def follow(structures_path: Path) -> tuple[int, str, pathlib.Path, dict[str, Any
             ssp = sub_p.parent / structure_path_str
             structure_info = load_yaml(ssp)
             if structure_info:
-                for facet in structure_info[target]:
-                    validate_facet(facet, ssp)
+                facets = structure_info.get(target)
+                if facets is None:
+                    log.warning(f'target ({target}) not found in data - skipping facet validation')
+                else:
+                    for facet in facets:
+                        validate_facet(facet, ssp)
     return 0, '', root_path, claims

#6 Pydantic V2 small issue a day ago

Comment by ~sthagen on ~sthagen/csaf

Fixed with version 2023.11.27

REPORTED RESOLVED FIXED

#6 Pydantic V2 small issue a day ago

Comment by ~sthagen on ~sthagen/csaf

Thank you for reporting the bug (implementation error).

The fix though should not be removing the constraint, but instead implement the correct one (https://docs.oasis-open.org/csaf/csaf/v2.0/os/csaf-v2.0-os.html#321121-document-property---tracking---aliases).

The min_length attribute in Pydantic is only valid for strings and aliases is a list (JSON array) of Alias elements.

So, I will add a validator "function" instead to the class. Something like:

class Tracking(BaseModel):
    # ...
    @classmethod
    @no_type_check
    @field_validator('aliases')
    def check_when_present_not_empty(cls, v):
        if not v:
            raise ValueError('optional element if present must not be empty')
        return v

#6 Pydantic V2 small issue a day ago

~sthagen assigned ~sthagen to #6 on ~sthagen/csaf

#6 Pydantic V2 small issue a day ago

Bug added by ~sthagen on ~sthagen/csaf

#56 Fix injection of blank lines in mermaid derived figure environments 2 days ago

~sthagen assigned ~sthagen to #56 on ~sthagen/liitos

#56 Fix injection of blank lines in mermaid derived figure environments 2 days ago

Bug added by ~sthagen on ~sthagen/liitos

#56 Fix injection of blank lines in mermaid derived figure environments 2 days ago

Ticket created by ~sthagen on ~sthagen/liitos

Currently the creation of figure environments from mermaid fenced blocks in markdown source files results in extra empty lines injected into the resulting LaTeX output file.

Example:

\begin{figure}

\centering

\includegraphics{images/foo-mermaid.png}
\caption{Foo \label{fig:foo}}

\end{figure}

This should really be:

\begin{figure}
\centering
\includegraphics{images/foo-mermaid.png}
\caption{Foo \label{fig:foo}}
\end{figure}