better-notion 2.1.6__py3-none-any.whl → 2.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -474,18 +474,19 @@ class WorkspaceInitializer:
474
474
  db = await self._client.databases.get(database_id)
475
475
  schema = db.schema
476
476
 
477
- # Add or update the relation property
478
- # Some properties (like Dependencies, Related Work Issue) are added AFTER
479
- # database creation, so they may not exist in the initial schema
477
+ # Prepare the new property schema
478
+ new_property_schema = None
479
+
480
480
  if property_name in schema:
481
481
  # Property exists, just update the database_id
482
- schema[property_name]["relation"]["database_id"] = target_database_id
482
+ new_property_schema = schema[property_name]
483
+ new_property_schema["relation"]["database_id"] = target_database_id
483
484
  else:
484
- # Property doesn't exist, ADD it
485
+ # Property doesn't exist, CREATE it
485
486
  # This handles cases where the property couldn't be in the initial schema
486
487
  if property_name == "Dependencies":
487
488
  # Self-referential relation
488
- schema[property_name] = {
489
+ new_property_schema = {
489
490
  "relation": {
490
491
  "database_id": database_id, # Self-reference
491
492
  "type": "dual_property",
@@ -497,7 +498,7 @@ class WorkspaceInitializer:
497
498
  }
498
499
  elif property_name == "Related Work Issue":
499
500
  # Relation to Work Issues database
500
- schema[property_name] = {
501
+ new_property_schema = {
501
502
  "relation": {
502
503
  "database_id": target_database_id,
503
504
  "type": "dual_property",
@@ -509,7 +510,7 @@ class WorkspaceInitializer:
509
510
  }
510
511
  elif property_name == "Blocking Tasks":
511
512
  # Relation from Work Issues to Tasks
512
- schema[property_name] = {
513
+ new_property_schema = {
513
514
  "relation": {
514
515
  "database_id": target_database_id,
515
516
  "type": "dual_property",
@@ -521,7 +522,7 @@ class WorkspaceInitializer:
521
522
  }
522
523
  elif property_name == "Caused Incidents":
523
524
  # Relation from Work Issues to Incidents
524
- schema[property_name] = {
525
+ new_property_schema = {
525
526
  "relation": {
526
527
  "database_id": target_database_id,
527
528
  "type": "dual_property",
@@ -533,7 +534,7 @@ class WorkspaceInitializer:
533
534
  }
534
535
  elif property_name == "Root Cause Work Issue":
535
536
  # Relation from Incidents to Work Issues
536
- schema[property_name] = {
537
+ new_property_schema = {
537
538
  "relation": {
538
539
  "database_id": target_database_id,
539
540
  "type": "dual_property",
@@ -545,21 +546,37 @@ class WorkspaceInitializer:
545
546
  }
546
547
  else:
547
548
  # Generic relation
548
- schema[property_name] = {
549
+ new_property_schema = {
549
550
  "relation": {
550
551
  "database_id": target_database_id,
551
552
  "dual_property": {}
552
553
  }
553
554
  }
554
555
 
555
- # Update the database schema via API
556
- await self._client._api._request(
557
- "PATCH",
558
- f"/databases/{database_id}",
559
- json={"properties": schema}
560
- )
556
+ # Send ONLY the new/updated property, not the entire schema
557
+ # This is the key fix - Notion API expects only the changed properties
558
+ update_payload = {"properties": {property_name: new_property_schema}}
561
559
 
562
- logger.info(f"Added/Updated {property_name} relation to {target_database_id}")
560
+ # Update the database schema via API
561
+ try:
562
+ await self._client._api._request(
563
+ "PATCH",
564
+ f"/databases/{database_id}",
565
+ json=update_payload
566
+ )
567
+ logger.info(f"Added/Updated {property_name} relation to {target_database_id}")
568
+ except Exception as e:
569
+ # Debug: Print schema details to see what's wrong
570
+ import sys
571
+ print(f"\n{'='*60}", file=sys.stderr)
572
+ print(f"❌ FAILED TO ADD PROPERTY: {property_name}", file=sys.stderr)
573
+ print(f"Database ID: {database_id}", file=sys.stderr)
574
+ print(f"Target: {target_database_id}", file=sys.stderr)
575
+ print(f"Payload being sent:", file=sys.stderr)
576
+ import json
577
+ print(json.dumps(update_payload, indent=2), file=sys.stderr)
578
+ print(f"{'='*60}\n", file=sys.stderr)
579
+ raise e
563
580
 
564
581
  def save_database_ids(self, path: Optional[Path] = None) -> None:
565
582
  """Save workspace metadata (database IDs and workspace info) to config file.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: better-notion
3
- Version: 2.1.6
3
+ Version: 2.1.7
4
4
  Summary: A high-level Python SDK for the Notion API with developer experience in mind.
5
5
  Project-URL: Homepage, https://github.com/nesalia-inc/better-notion
6
6
  Project-URL: Documentation, https://github.com/nesalia-inc/better-notion#readme
@@ -132,9 +132,9 @@ better_notion/utils/agents/project_context.py,sha256=aJlzy5H2rL4sAfW2jHL_3K2VkBJ
132
132
  better_notion/utils/agents/rbac.py,sha256=8ZA8Y7wbOiVZDbpjpH7iC35SZrZ0jl4fcJ3xWCm3SsE,11820
133
133
  better_notion/utils/agents/schemas.py,sha256=2QF71tL-lt_n7u-oizVDMj4nd29fl8uUbhMKTWxNzr4,22721
134
134
  better_notion/utils/agents/state_machine.py,sha256=xUBEeDTbU1Xq-rsRo2sbr6AUYpYrV9DTHOtZT2cWES8,6699
135
- better_notion/utils/agents/workspace.py,sha256=21T0aQ2MYq60jJvaBvcdUCHZT7JENZ-4VciS5Z-5_X0,25736
136
- better_notion-2.1.6.dist-info/METADATA,sha256=MYHP3_45OizHx44DSa7COKpPa2ByMkZXnx9966IYv9o,11096
137
- better_notion-2.1.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
138
- better_notion-2.1.6.dist-info/entry_points.txt,sha256=D0bUcP7Z00Zyjxw7r2p29T95UrwioDO0aGDoHe9I6fo,55
139
- better_notion-2.1.6.dist-info/licenses/LICENSE,sha256=BAdN3JpgMY_y_fWqZSCFSvSbC2mTHP-BKDAzF5FXQAI,1069
140
- better_notion-2.1.6.dist-info/RECORD,,
135
+ better_notion/utils/agents/workspace.py,sha256=2_dK58fifMqSEifFxThI7ir_1UR9KLN-d6R4CkdNqjQ,26538
136
+ better_notion-2.1.7.dist-info/METADATA,sha256=ZOWG_6BbvfRNEtgve-N-bCSSP20h4lotU6bT6k0Hvlk,11096
137
+ better_notion-2.1.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
138
+ better_notion-2.1.7.dist-info/entry_points.txt,sha256=D0bUcP7Z00Zyjxw7r2p29T95UrwioDO0aGDoHe9I6fo,55
139
+ better_notion-2.1.7.dist-info/licenses/LICENSE,sha256=BAdN3JpgMY_y_fWqZSCFSvSbC2mTHP-BKDAzF5FXQAI,1069
140
+ better_notion-2.1.7.dist-info/RECORD,,