← back to Dw Material Envelope Canary

__pycache__/check.cpython-314.pyc

53 lines

+
�WMj���d�Rt^RIt^RIt^RIt^RIt^RIt^RIt]PP]PP]44tRt
]
!4]PPRR4t]PPR4;'g]PPR4t]'g]P$!R4R]R	2tR
t.ROtRP-R]!]444tR
],R,tRtRtRt]R8Xd]P$!]!44R#R#)u4dw-material-envelope-canary — READ-ONLY recurrence monitor.

Scans the live DW Shopify catalog for the double-encoded metafield bug where a
value leaked its raw JSON wrapper, e.g. {"type": "single_line_text_field",
"value": "Paper"} — instead of the plain value. Born 2026-07-07 after a Python
importer double-encoded custom.material + dwc.contents on 571 products.

Alerts (CNCP parking-lot card) ONLY on FAIL (>0 envelopes found). PASS is silent.
Always writes data/latest.json so the canary meta-watchdog sees it ran.
Touches nothing — pure GraphQL reads.Nc�F�\PPR4\PP\R43F�p\PPV4'gK*\
V4F�pRV9gKVP4PR4'dK3VP4PR^4wr#\PPW#P4PR4PR44K�	K�	R#)z&~/Projects/Designer-Wallcoverings/.envz.env�=�#�"�'N)�os�path�
expanduser�join�HERE�exists�open�strip�
startswith�split�environ�
setdefault)�p�ln�k�vs    �check.py�load_envrs����g�g� � �!I�J��g�g�l�l�4��(�*��
�7�7�>�>�!����1�g���"�9�R�X�X�Z�%:�%:�3�%?�%?��8�8�:�+�+�C��3�D�A��J�J�)�)�!�W�W�Y�_�_�S�-A�-G�-G��-L�M��*��SHOPIFY_STORE_DOMAINz)designer-laboratory-sandbox.myshopify.com�SHOPIFY_ADMIN_TOKEN�SHOPIFY_ADMIN_ACCESS_TOKENzQERROR: SHOPIFY_ADMIN_TOKEN not set (check ~/Projects/Designer-Wallcoverings/.env)zhttps://z/admin/api/2024-01/graphql.jsonz%http://127.0.0.1:3333/api/parking_lot� c#�D"�TFwpwr#RVRVRVR2x�K	R#5i)rz: metafield(namespace:"z", key:"z"){ value }N�)�.0�i�nsrs&   r�	<genexpr>r#"s3���;�$9�j�a��"��a�S�/��t�8�A�3�m�L�$9�s� znquery($c:String){ products(first:200, after:$c){ pageInfo{ hasNextPage endCursor } edges{ node{ handle status z } } } }c�(�\P!R\RRV//4P4p\P
P
\VR\RR/R7p\^4F�p\P
PV^<R7;_uu_4p\P!VP44pRRR4XPR	4'dh\;QJd#R
VR	,4F'gKRM	RM!R
VR	,44'd \P !^V,4K�Vu#	\%R
4h +'giL�;i \"d#\P !^T,4EK(i;i)�query�	variables�czX-Shopify-Access-Token�Content-Type�application/json��data�headers��timeoutN�errorsc3�Z"�TF!pR\V4P49x�K#	R#5i)�throttlN)�str�lower)r �es& rr#�gql.<locals>.<genexpr>.s���&X�K�q�y�C��F�L�L�N�'B�K�s�)+TFz
gql failed)�json�dumps�QUERY�encode�urllib�request�Request�URL�TOK�range�urlopen�loads�read�get�any�time�sleep�	Exception�
SystemExit)�cursor�body�req�attempt�r�ds&     r�gqlrO&s���:�:�w��{�S�&�M�B�C�J�J�L�D�
�.�.�
 �
 ��4� �#�~�7I�:K�
 �L�C���8��	$����'�'��R�'�8�8�A��J�J�q�v�v�x�(��9��u�u�X���3�3�&X�A�h�K�&X�3�3�3�&X�A�h�K�&X�#X�#X��
�
�1�w�;�'���H�
��\�
"�"�9�8��
�	$��J�J�q�7�{�#�#�	$�sH�,)E$�%E�:E$�
E$�$E$�?!E$�!E$�E$�E!�E$�$(F�Fc�<�\V\4;'dRV9#)�single_line_text_field)�
isinstancer2)rs&r�is_envrS5s���a���?�?�":�a�"?�?rc���\P!\PP\R4RR7^p.pRp\V4R,R,pVR,F�pVR,qP^,
p\
\4FswpwrxVPRV24p	V	'gK&\V	PR44'gKHVPR	VR	,R
VR
,RVRV2/4K�	K�	VR
,R,'gMVR
,R,pK�V'dRMRp
R\PP4P4RVR\V4RV
RVR,/p\\PP\RR4R4;_uu_4p\ P"!W�^R7RRR4\%V
RVR\V4R24V'd�\'RV44p
RR \V4R!V
R"2R#R$RPR%VR&,44R'2R(R)/p\(P*P-\(P*P/\0\ P2!V4P54R*R+/R,7^R-7\%R.4V'd^#^# +'giEL;i \6dp\%R/T4Rp?L<Rp?ii;i)0r+T)�exist_okN�products�edges�noder�value�handle�status�field�.�pageInfo�hasNextPage�	endCursor�FAIL�PASS�ts�scanned�broken�verdict�sample:N�Nzlatest.json�w)�indentz
: scanned z, z envelope-corruptedc3�D"�TFqR,R8XgK^x�K	R#5i)r[�ACTIVENr�r �bs& rr#�main.<locals>.<genexpr>Ss���C�C�q�X�;�(�+B���C�s� �
 �titleu%⚠️ Material envelope regression: z products (z ACTIVE)�notezYdw-material-envelope-canary found metafield values leaking raw JSON wrappers again. e.g. c3�2"�TF
qR,x�K	R#5i)rZNrrms& rr#roVs���-K�7�a��k�k�7�s�:N�Nz4. Re-run /tmp/fix_material.py or check the importer.�sourcezdw-material-envelope-canaryr(r)r*r-z  posted CNCP alertz  CNCP post failed:)r�makedirsrr
rrO�	enumerate�
CHECK_KEYSrCrS�append�datetime�now�	isoformat�lenr
r6�dump�print�sumr:r;r@r<�CNCPr7r9rG)�total�badrI�connr4�nr!r"r�mfrf�result�fh�active�card�exs                r�mainr�;s����K�K������T�6�*�T�:�
�E�R�s�
�F�
��6�{�6�"�:�.���g���A��&�	�A�A�:�5�'�
�3�
��7�B��U�U�Q�q�c�7�^���2�&������1�1��J�J��!�H�+�x��8��g�Z\�Y]�]^�_`�^a�Wb�c�d��	4���J��
�.�.���j�!�+�.���f��G��H�%�%�)�)�+�5�5�7��E���C��)�W�h��C��J�F�	
�b�g�g�l�l�4���7��	=�	=���	�	�&�Q�'�
>�	�W�I�Z��w�b��S��
�2E�
F�G�
�	-��C�C�C�C�F��D�S��X�J�k�Z`�Ya�ai�j��$�$(�I�I�-K�3�r�7�-K�$K�#L�MA�B��;�=�D�
�N�N�"�"�6�>�>�#9�#9��4�:�:�d�+�2�2�4�'�);�<�$:�$>�GH�
#�
J�
�'�(��1����!
>�	=�	=���	-��'��,�,��	-�s%�4K�;B?K�K	�K;�%K6�6K;�__main__))�custom�material)�dwc�contents)�global�Material)�__doc__rr6�sysrE�urllib.requestr:ryr�dirname�abspath�__file__rrrrC�DOMAINr>�exitr=r�rwr
rv�FIELDSr8rOrSr��__name__rrr�<module>r�s��	+�5�4�4�	�w�w���r�w�w���x�0�1��N�	�
�	�����.�0[�	\���j�j�n�n�*�+�[�[�r�z�z�~�~�>Z�/[��
��H�H�
`�a����7�8��.��S�
�	���;�$-�j�$9�;�
;��x�|B�	B�EO�	O��
#�@�#�J�z���H�H�T�V��r