Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from fastapi import FastAPI

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unconditional Import for Optional API Hook

Low Severity

from fastapi import FastAPI is an unconditional top-level import in the template, while every other optional import (ObjectStorageService, Secret, TripleStoreService, VectorStoreService) is commented out. The api method it supports is explicitly documented as optional, yet the import it depends on is always active. This breaks the template's established convention: optional capabilities are shown as commented examples that developers uncomment when needed. As a result, every generated module carries a live fastapi import regardless of whether the author ever uses the API hook.

Additional Locations (1)

Fix in Cursor Fix in Web

from naas_abi_core.module.Module import (
BaseModule,
ModuleConfiguration,
Expand Down Expand Up @@ -39,3 +40,17 @@ def on_initialized(self):
# You can see it as the constructor of the module.
def on_load(self):
super().on_load()

# Optional FastAPI integration hook.
# This mirrors how `naas_abi` wires API settings and services into app.state.
# Override and adapt to your module if you expose HTTP routes.
def api(self, app: FastAPI) -> None:
# Example: expose services to your API layer.
# app.state.object_storage = self.engine.services.object_storage
# app.state.secret_service = self.engine.services.secret
# app.state.triple_store = self.engine.services.triple_store

# Example: mount your FastAPI routes/app factory.
# from your_module.apps.api.app.main import create_app
# create_app(app)
pass