Skip to content

fix(backend): Validate 'name' attribute when constructing AgentInput/OutputBlock - #11250

Open
seer-by-sentry[bot] wants to merge 4 commits into
devfrom
seer/fix-missing-name-validation
Open

fix(backend): Validate 'name' attribute when constructing AgentInput/OutputBlock#11250
seer-by-sentry[bot] wants to merge 4 commits into
devfrom
seer/fix-missing-name-validation

Conversation

@seer-by-sentry

Copy link
Copy Markdown
Contributor

Changes 🏗️

Fixes BUILDER-4E2. The issue was that: Input/Output node data is missing the required 'name' field, causing Pydantic's model_construct to create an incomplete object lacking the 'name' attribute, resulting in an AttributeError during schema generation.

  • Added validation to ensure that constructed AgentInputBlock and AgentOutputBlock objects have a 'name' attribute.
  • Log a warning and skip the node if the 'name' attribute is missing or None, preventing potential errors during graph processing.

This fix was generated by Seer in Sentry, triggered automatically. 👁️ Run ID: 2182742

Not quite right? Click here to continue debugging with Seer.

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • Need to create a test plan
Example test plan
  • Create from scratch and execute an agent with at least 3 blocks
  • Import an agent from file upload, and confirm it executes correctly
  • Upload agent to marketplace
  • Import an agent from marketplace and confirm it executes correctly
  • Edit an agent from monitor, and confirm it executes correctly

For configuration changes:

  • .env.default is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)
Examples of configuration changes
  • Changing ports
  • Adding new services that need to communicate with each other
  • Secrets or environment variable changes
  • New or infrastructure changes such as databases

@seer-by-sentry
seer-by-sentry Bot requested a review from a team as a code owner October 25, 2025 10:46
@seer-by-sentry
seer-by-sentry Bot requested review from Pwuts and kcze and removed request for a team October 25, 2025 10:46
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Oct 25, 2025
@netlify

netlify Bot commented Oct 25, 2025

Copy link
Copy Markdown

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 06a4e4d
🔍 Latest deploy log https://app.netlify.com/projects/auto-gpt-docs/deploys/68fcaa9b44484f00089efaae

@sentry

sentry Bot commented Oct 25, 2025

Copy link
Copy Markdown

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: autogpt_platform/backend/backend/data/graph.py

Function Unhandled Issue
_generate_schema AttributeError: 'Input' object has no attribute 'name' /api/graphs/{gra...
Event Count: 5

@coderabbitai

coderabbitai Bot commented Oct 25, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the platform/backend AutoGPT Platform - Back end label Oct 25, 2025
@github-actions

Copy link
Copy Markdown
Contributor

This PR targets the master branch but does not come from dev or a hotfix/* branch.

Automatically setting the base branch to dev.

@github-actions
github-actions Bot changed the base branch from master to dev October 25, 2025 10:47
@deepsource-io

deepsource-io Bot commented Oct 25, 2025

Copy link
Copy Markdown

Here's the code health analysis summary for commits acb9468..06a4e4d. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗
DeepSource Python LogoPython✅ Success
❗ 1 occurence introduced
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@AutoGPT-Agent

Copy link
Copy Markdown
Contributor

Thank you for this fix to validate the 'name' attribute for AgentInput/OutputBlock objects. I have a few concerns before we can merge this PR:

  1. The PR checklist is incomplete - please check off the items you've completed and provide a test plan for how you've verified this fix works correctly.

  2. There are several changes in block_cost_config.py that aren't mentioned in your PR description, including:

    • Adding imports for AIAdMakerVideoCreatorBlock and AIScreenshotToVideoAdBlock
    • Changing the cost_amount for AIShortformVideoCreatorBlock from 50 to 307
    • Adding cost configurations for AIAdMakerVideoCreatorBlock and AIScreenshotToVideoAdBlock

    These changes should either be removed from this PR or explained in the description.

  3. Please verify that your fix works by creating a test plan and confirming that it resolves the AttributeError issue mentioned in the Sentry report.

Once you address these items, we can move forward with the merge.

@AutoGPT-Agent

Copy link
Copy Markdown
Contributor

Thank you for submitting this fix for the validation issue with the 'name' attribute in AgentInput/OutputBlock construction. The PR has a good description explaining the problem and solution.

However, there are two issues that need to be addressed before this PR can be merged:

  1. Incomplete Checklist: The checklist items in your PR description are not checked off. You've noted that you need to create a test plan, but haven't completed this step. Please create a test plan and check off all the relevant items in the checklist.

  2. Out of Scope Changes: There are changes to block_cost_config.py that appear unrelated to the validation fix described in your PR. These include:

    • Adding imports for AIAdMakerVideoCreatorBlock and AIScreenshotToVideoAdBlock
    • Updating the cost amount for AIShortformVideoCreatorBlock
    • Adding cost configurations for the newly imported block types

    These changes aren't mentioned in your PR description and don't seem directly related to the 'name' attribute validation fix. Please either:

    • Explain how these changes are related to the validation fix
    • Remove them from this PR and submit them as a separate PR
    • Update your PR title and description to include these changes

Once these issues are addressed, we can proceed with the review process.

@Pwuts Pwuts left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't this be fixed much simpler by using model_validate?

Also this PR contains a bunch of unrelated changes, pls fix

@github-project-automation github-project-automation Bot moved this from 🆕 Needs initial review to 🚧 Needs work in AutoGPT development kanban Oct 26, 2025
@ntindle

ntindle commented Dec 18, 2025

Copy link
Copy Markdown
Member

@cursor Can't this be fixed much simpler by using model_validate?

Also this PR contains a bunch of unrelated changes, pls fix

@cursor

cursor Bot commented Dec 18, 2025

Copy link
Copy Markdown

model_validate blows up as soon as any required field is missing, and the builder intentionally lets users save partially configured nodes (e.g., an input block with no default for a required field yet). _generate_schema only needs the pieces that are present so we can surface whatever fields do have defaults; running full validation would raise and prevent the entire graph schema from rendering whenever a user has an in-progress node. That’s why this function has always relied on model_construct and why I limited the new guard to just the name attribute that the JSON schema builder actually dereferences.

267:299:autogpt_platform/backend/backend/data/graph.py
            try:
                constructed_obj = type_class.model_construct(**input_default)
                if not hasattr(constructed_obj, "name") or constructed_obj.name is None:
                    logger.warning(
                        f"Skipping invalid {type_class.__name__} node: missing required 'name' field. "
                        f"Input data: {input_default}"
                    )
                    continue
                schema_fields.append(constructed_obj)
            except Exception as e:
                logger.error(f"Invalid {type_class}: {input_default}, {e}")

On the unrelated changes: good catch—those block_cost_config.py tweaks came along for the ride from another branch. I’m stripping them (and anything else unrelated) out so this PR only touches the validation fix, then I’ll push an updated diff.


Open in Cursor Open in Web

Learn more about Cursor Agents

@cursor

cursor Bot commented Dec 18, 2025

Copy link
Copy Markdown

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@nidhishgajjar

This comment was marked as low quality.

@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

🔍 PR Overlap Detection

This check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early.

🔴 Merge Conflicts Detected

The following PRs have been tested and will have merge conflicts if merged after this PR. Consider coordinating with the authors.

🟢 Low Risk — File Overlap Only

These PRs touch the same files but different sections (click to expand)

Summary: 1 conflict(s), 0 medium risk, 5 low risk (out of 6 PRs with file overlap)


Auto-generated on push. Ignores: openapi.json, lock files.

@ntindle

ntindle commented Apr 15, 2026

Copy link
Copy Markdown
Member

@copilot fix this pr up and get it in tip top shape addressing any comments that need to be addressed and resolving them. /pr-address will be your friend. @Pwuts may need re-requested for review if you think this is still a good idea. if not, recommend we close it (or close it yourself)

Comment thread autogpt_platform/backend/backend/data/graph.py Outdated
@codecov

codecov Bot commented Apr 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.97%. Comparing base (1ed2d42) to head (5df0753).
⚠️ Report is 15 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #11250      +/-   ##
==========================================
- Coverage   71.42%   68.97%   -2.46%     
==========================================
  Files        2212     2097     -115     
  Lines      166792   165326    -1466     
  Branches    17035    16764     -271     
==========================================
- Hits       119136   114028    -5108     
- Misses      44108    48078    +3970     
+ Partials     3548     3220     -328     
Flag Coverage Δ
platform-backend 79.77% <100.00%> (-0.01%) ⬇️
platform-frontend-e2e 30.98% <ø> (-0.41%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 79.77% <100.00%> (-0.01%) ⬇️
Platform Frontend 26.47% <ø> (-15.36%) ⬇️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Can't this be fixed much simpler by using model_validate?

Also this PR contains a bunch of unrelated changes, pls fix

Agreed — replaced model_construct with model_validate in 17cbeca. This lets Pydantic's built-in validation catch missing name (and any other invalid data), which is then handled by the existing except Exception block. Also removed all unrelated changes — the PR now only touches graph.py with a single-line semantic change.

@copilot fix this pr up and get it in tip top shape addressing any comments that need to be addressed and resolving them. /pr-address will be your friend. @Pwuts may need re-requested...

Addressed all comments in 17cbeca:

  1. Replaced model_constructmodel_validate as @Pwuts suggested — much simpler fix that lets Pydantic handle validation natively
  2. Removed all unrelated changes — PR now only contains a single-line change in graph.py
  3. Removed the manual hasattr/name check and extra try/except AttributeError wrapper since model_validate handles this automatically

The diff against dev is now minimal: just model_construct(**input_default)model_validate(input_default).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr list --head seer/fix-missing-name-validation --repo Significant-Gravitas/AutoGPT 325fa485a6f4ca17a65a6d74e1ddbf1ca7950a6fa9ff2191d7d2df0b3441b418 by/325fa485a6f4ccat fb7b6848408adbb2/usr/local/kong/pids/nginx.pid (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@CLAassistant

CLAassistant commented May 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the conflicts Automatically applied to PRs with merge conflicts label May 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Automatically applied to PRs with merge conflicts platform/backend AutoGPT Platform - Back end size/m

Projects

Status: 🚧 Needs work

Development

Successfully merging this pull request may close these issues.

6 participants