Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/StatPan/dlfrnaos19-infra/dispatches \
-d "{
\"event_type\": \"deploy-assemblymcp\",
\"event_type\": \"deploy-assemblymcp-oracle\",
\"client_payload\": {
\"image_tag\": \"$IMAGE_TAG\",
\"repository\": \"${{ github.repository }}\",
Expand Down
28 changes: 13 additions & 15 deletions assemblymcp/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,19 @@ async def get_bill_info(
"""
params = {
"AGE": age, # REQUIRED
"BILL_ID": bill_id,
"BILL_NAME": bill_name,
"PROPOSE_DT": propose_dt,
"PROC_RESULT_CD": proc_status,
"pIndex": page,
"pSize": limit,
}

if bill_id:
# Check if bill_id is numeric (likely a BILL_NO)
if bill_id.isdigit():
params["BILL_NO"] = bill_id
else:
params["BILL_ID"] = bill_id
Comment on lines +264 to +269
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current logic for determining if a bill_id is numeric doesn't account for leading/trailing whitespace. A bill_id like ' 12345 ' would fail the isdigit() check and be incorrectly treated as an alphanumeric BILL_ID. It's better to strip whitespace from bill_id before checking if it's numeric to handle such cases correctly. The logic can also be made more concise.

Suggested change
if bill_id:
# Check if bill_id is numeric (likely a BILL_NO)
if bill_id.isdigit():
params["BILL_NO"] = bill_id
else:
params["BILL_ID"] = bill_id
if bill_id:
stripped_id = bill_id.strip()
if stripped_id:
# Check if bill_id is numeric (likely a BILL_NO)
key = "BILL_NO" if stripped_id.isdigit() else "BILL_ID"
params[key] = stripped_id

# Filter out None values
params = {k: v for k, v in params.items() if v is not None}

Expand Down Expand Up @@ -322,20 +328,12 @@ async def get_bill_details(self, bill_id: str, age: str | None = None) -> BillDe
target_bill = bills[0]
else:
# Strategy: Try to find the bill in recent sessions
# If bill_id looks like a numeric ID (e.g. 2214308), we can't search by BILL_ID in
# get_bill_info because get_bill_info expects the alphanumeric ID (PRC_...).
# However, we can try to find it by BILL_NO if we had a way to search by BILL_NO.
# The current get_bill_info implementation maps `bill_id` arg to `BILL_ID` param.

# Heuristic: If ID is numeric and length is around 7, it's likely a BILL_NO.
is_numeric_id = bill_id.isdigit() and len(bill_id) < 10

if not is_numeric_id:
for probe_age in ["22", "21"]:
bills = await self.get_bill_info(age=probe_age, bill_id=bill_id)
if bills:
target_bill = bills[0]
break
# Now that get_bill_info supports BILL_NO, we can try searching directly
for probe_age in ["22", "21"]:
bills = await self.get_bill_info(age=probe_age, bill_id=bill_id)
if bills:
target_bill = bills[0]
break

# If we didn't find a bill object but have a numeric ID, we might still be able to fetch
# details directly using the numeric ID as BILL_NO.
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading